commit 4cd01361976d17e7c8ca4a0eae52a2a1cdca66c3 Author: ChrisChrome Date: Tue Oct 8 08:58:09 2024 -0600 Had to redo the whole repo, fun fun diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..69f2275 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +old/ \ No newline at end of file diff --git a/AudioInit.rbxm b/AudioInit.rbxm new file mode 100644 index 0000000..2871d00 Binary files /dev/null and b/AudioInit.rbxm differ diff --git a/PagingSystemv1.rbxm b/PagingSystemv1.rbxm new file mode 100644 index 0000000..54786c4 Binary files /dev/null and b/PagingSystemv1.rbxm differ diff --git a/Parts/Base/BGMPlayer.ChrisChrome.rbxm.broken b/Parts/Base/BGMPlayer.ChrisChrome.rbxm.broken new file mode 100644 index 0000000..d347d97 Binary files /dev/null and b/Parts/Base/BGMPlayer.ChrisChrome.rbxm.broken differ diff --git a/Parts/Base/BellSystem.ChrisChrome.rbxm b/Parts/Base/BellSystem.ChrisChrome.rbxm new file mode 100644 index 0000000..d9b6df7 Binary files /dev/null and b/Parts/Base/BellSystem.ChrisChrome.rbxm differ diff --git a/Parts/Base/MainStruct.ChrisChrome.rbxm b/Parts/Base/MainStruct.ChrisChrome.rbxm new file mode 100644 index 0000000..543edf0 Binary files /dev/null and b/Parts/Base/MainStruct.ChrisChrome.rbxm differ diff --git a/Parts/Base/Zone.ChrisChrome.rbxm b/Parts/Base/Zone.ChrisChrome.rbxm new file mode 100644 index 0000000..f616240 Binary files /dev/null and b/Parts/Base/Zone.ChrisChrome.rbxm differ diff --git a/Parts/Speakers/AtlasEDVP161.Miko.rbxm b/Parts/Speakers/AtlasEDVP161.Miko.rbxm new file mode 100644 index 0000000..e71b6dc Binary files /dev/null and b/Parts/Speakers/AtlasEDVP161.Miko.rbxm differ diff --git a/Parts/Speakers/Bullhorn.Miko.rbxm b/Parts/Speakers/Bullhorn.Miko.rbxm new file mode 100644 index 0000000..adc42c1 Binary files /dev/null and b/Parts/Speakers/Bullhorn.Miko.rbxm differ diff --git a/Parts/Stations/AllZoneStation.TazTech.rbxm b/Parts/Stations/AllZoneStation.TazTech.rbxm new file mode 100644 index 0000000..5059985 Binary files /dev/null and b/Parts/Stations/AllZoneStation.TazTech.rbxm differ diff --git a/Parts/Stations/FancyStation.Bryce.rbxm b/Parts/Stations/FancyStation.Bryce.rbxm new file mode 100644 index 0000000..5088171 Binary files /dev/null and b/Parts/Stations/FancyStation.Bryce.rbxm differ diff --git a/Parts/Stations/MultiPlayer.rbxm b/Parts/Stations/MultiPlayer.rbxm new file mode 100644 index 0000000..ef4fe71 Binary files /dev/null and b/Parts/Stations/MultiPlayer.rbxm differ diff --git a/Parts/Stations/SingleZoneMultiPlayer.rbxm b/Parts/Stations/SingleZoneMultiPlayer.rbxm new file mode 100644 index 0000000..3a12cca Binary files /dev/null and b/Parts/Stations/SingleZoneMultiPlayer.rbxm differ diff --git a/Parts/Stations/SingleZoneStation.TazTech.rbxm b/Parts/Stations/SingleZoneStation.TazTech.rbxm new file mode 100644 index 0000000..c9b71e9 Binary files /dev/null and b/Parts/Stations/SingleZoneStation.TazTech.rbxm differ diff --git a/Parts/Stations/Station.TazTech.rbxm b/Parts/Stations/Station.TazTech.rbxm new file mode 100644 index 0000000..f81e16b Binary files /dev/null and b/Parts/Stations/Station.TazTech.rbxm differ diff --git a/README.md b/README.md new file mode 100644 index 0000000..d4115b7 --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +# Paging System +The models used here were created and graciously donated by [Taz Tech](https://www.roblox.com/groups/12396612/Liminal-Existance-Group) + +## Legal Stuff +

All Models Used by TazTech/Liminal Existance Group is licensed under CC BY-NC-SA 4.0

+ +Scripts are licensed under GPL-3.0 or later + +## Basic Setup +- TODO: Setup instructions. + +## AudioInit.rbxm +- This is used to initialize the mic and speaker objects for each player. Place this in StarterCharacterScripts. + +## Important Note +- The Audio API Beta needs to be enabled for this to work. +- The UseAudioApi property of VoiceChatService (hidden, enable in Explorer studio settings) needs to be set to Enabled for the microphone to work at all. \ No newline at end of file diff --git a/Scripts/AllZones.lua b/Scripts/AllZones.lua new file mode 100644 index 0000000..7f7bf11 --- /dev/null +++ b/Scripts/AllZones.lua @@ -0,0 +1,172 @@ +local system = script.Parent.Parent.Parent +local zones = {} +local mic = script.Parent.WallMic["Mic Enclosure"].AudioListener +local buttons = {} +local led = script.Parent.LED +local ptt = false +pttButton = script.Parent.WallMic["Mic Enclosure"].CD +local tones = {} +local thisTimeout = nil +local systemReady = true +local systemOverride = script.Parent.override.Value +local TweenService = game:GetService("TweenService") +local waiting = false + +function smoothTransition(startValue, endValue, duration, updateFunction) + local finished = false + -- Create a temporary NumberValue to tween + local numberValue = Instance.new("NumberValue") + numberValue.Value = startValue + + -- Create TweenInfo + local tweenInfo = TweenInfo.new( + duration, -- Duration of the tween + Enum.EasingStyle.Linear, -- Easing style + Enum.EasingDirection.InOut, -- Easing direction + 0, -- Number of times to repeat + false, -- Whether to reverse the tween + 0 -- Delay time before starting the tween + ) + + -- Create tween goal + local tweenGoal = {Value = endValue} + + -- Create the tween + local tween = TweenService:Create(numberValue, tweenInfo, tweenGoal) + + -- Connect the update function to the Changed event + local connection + connection = numberValue.Changed:Connect(function() + -- Call the update function with the current value + updateFunction(numberValue.Value) + end) + + -- Play the tween + tween:Play() + + -- Cleanup after tween completes + tween.Completed:Connect(function() + -- Ensure the final value is set to endValue + updateFunction(endValue) + -- Disconnect the event and remove the NumberValue instance + connection:Disconnect() + numberValue:Destroy() + finished = true + end) + repeat wait() until finished + finished = false +end + +function checkZones() + while true do + systemReady = true + for i,e in pairs(zones) do + if e.ZoneInput.Wire.Connected then + if not systemOverride then + systemReady = false + end + end + end + if not ptt then + if not systemReady then + led.Material = Enum.Material.Neon + led.Color = Color3.new(1,0,0) + else + led.Material = Enum.Material.SmoothPlastic + led.Color = Color3.new(202/255, 203/255, 209/255) + end + end + wait(0) + end +end +function checkReady() + while true do + ready = true + for i,e in pairs(zones) do + local thisTone = tones[e.PageTone.Value] + if thisTone.TimeLength == 0 then + -- Empty audio, stop playing it + thisTone:Stop() + end + if thisTone.IsPlaying or waiting then + ready = false + end + end + if ready and ptt then + -- set led to green + led.Material = Enum.Material.Neon + led.Color = Color3.new(0,1,0) + elseif ptt then + -- set led to solid yellow + led.Material = Enum.Material.Neon + led.Color = Color3.new(1,1,0) + end + wait() + end +end +function togglePTT() + print(ready) + print("toggling ptt") + if ptt then + ptt = false + print("off") + thisTimeout = nil + for i,e in pairs(zones) do + task.spawn(function() + local thisTone = tones[zones[e.Name].EndTone.Value] + zones[e.Name].ZoneInput.Wire.SourceInstance = thisTone + thisTone:Play() + wait(thisTone.TimeLength) + zones[e.Name].ZoneInput.Wire.SourceInstance = nil + smoothTransition(zones[e.Name].BGM.Volume,script.Parent.BGMUp.Value, 1, function(value) + zones[e.Name].BGM.Volume = value + end) + end) + end + else + if not systemReady then return end + ptt = true + for i,e in pairs(zones) do + task.spawn(function() + local thisTone = tones[zones[e.Name].PageTone.Value] + waiting = true + smoothTransition(zones[e.Name].BGM.Volume, script.Parent.BGMDown.Value, 1, function(value) + zones[e.Name].BGM.Volume = value + end) + waiting = false + zones[e.Name].ZoneInput.Wire.SourceInstance = thisTone + thisTone:Play() + wait(thisTone.TimeLength) + if(ptt) then + -- We havent stopped PTT before page tone done, hit it + zones[e.Name].ZoneInput.Wire.SourceInstance = script.Parent.StationOutput + thisTimeout = math.random(1,1000000) + task.spawn(function() + local myTimeout = tonumber(tostring(thisTimeout)) + wait(script.Parent.TimeoutSeconds.Value) + if myTimeout == thisTimeout then + togglePTT() + end + end) + end + end) + end + end + +end + + +pttButton.MouseClick:Connect(function() + togglePTT() +end) + +for i,e in ipairs(system.Zones:GetChildren()) do + zones[e.Name] = e +end + +for i,e in ipairs(system.Tones:GetChildren()) do + tones[e.Name] = e +end + +task.spawn(checkZones) +task.spawn(checkReady) \ No newline at end of file diff --git a/Scripts/ButtonLeds.lua b/Scripts/ButtonLeds.lua new file mode 100644 index 0000000..93457eb --- /dev/null +++ b/Scripts/ButtonLeds.lua @@ -0,0 +1,223 @@ +local system = script.Parent.Parent.Parent +local zones = {} +local mic = script.Parent["Panel Mic"].mic.AudioListener +local buttons = {} +local leds = {} +local ptt = false +pttButton = script.Parent["Panel Mic"].mic.CD +local selectedZones = {} +local tones = {} +local thisTimeout = nil +local waiting = false +local TweenService = game:GetService("TweenService") + +function smoothTransition(startValue, endValue, duration, updateFunction) + local finished = false + -- Create a temporary NumberValue to tween + local numberValue = Instance.new("NumberValue") + numberValue.Value = startValue + + -- Create TweenInfo + local tweenInfo = TweenInfo.new( + duration, -- Duration of the tween + Enum.EasingStyle.Linear, -- Easing style + Enum.EasingDirection.InOut, -- Easing direction + 0, -- Number of times to repeat + false, -- Whether to reverse the tween + 0 -- Delay time before starting the tween + ) + + -- Create tween goal + local tweenGoal = {Value = endValue} + + -- Create the tween + local tween = TweenService:Create(numberValue, tweenInfo, tweenGoal) + + -- Connect the update function to the Changed event + local connection + connection = numberValue.Changed:Connect(function() + -- Call the update function with the current value + updateFunction(numberValue.Value) + end) + + -- Play the tween + tween:Play() + + -- Cleanup after tween completes + tween.Completed:Connect(function() + -- Ensure the final value is set to endValue + updateFunction(endValue) + -- Disconnect the event and remove the NumberValue instance + connection:Disconnect() + numberValue:Destroy() + finished = true + end) + repeat wait() until finished + finished = false +end + +function toggleZone(zoneNumber) + if ptt then return end -- We're transmitting, don't toggle zones + if selectedZones[zoneNumber] then + selectedZones[zoneNumber] = nil + leds[zoneNumber].Color = Color3.new(202/255, 203/255, 209/255) + leds[zoneNumber].Material = Enum.Material.SmoothPlastic + else + if zones[zoneNumber].ZoneInput.Wire.Connected then + -- Nothing, in use + else + selectedZones[zoneNumber] = zones[zoneNumber] + end + end +end + +function flashSelected() + local state = false + while true do + while not ptt do + for i,e in pairs(selectedZones) do + if state then + leds[i].Material = Enum.Material.SmoothPlastic + leds[i].Color = Color3.new(202/255, 203/255, 209/255) + else + leds[i].Material = Enum.Material.Neon + leds[i].Color = Color3.new(1,1,0) + end + end + state = not state + wait(.2) + end + wait() + end +end + +function checkZones() + while true do + for i,e in pairs(leds) do + if not selectedZones[e.Name] then + if zones[e.Name].ZoneInput.Wire.Connected then + e.Material = Enum.Material.Neon + e.Color = Color3.new(1,0,0) + else + e.Material = Enum.Material.SmoothPlastic + e.Color = Color3.new(202/255, 203/255, 209/255) + end + elseif not ptt and selectedZones[e.Name] and zones[e.Name].ZoneInput.Wire.Connected then + -- Someone else took the zone, drop it from selections + toggleZone(e.Name) + end + end + wait(0) + end +end +function checkReady() + local ready = true + while true do + if ptt then + ready = true + for i,e in pairs(selectedZones) do + print("checking " .. e.Name) + leds[e.Name].Material = Enum.Material.Neon + local thisTone = tones[e.PageTone.Value] + if thisTone.TimeLength == 0 then + -- Empty audio, stop playing it + thisTone:Stop() + end + if waiting or thisTone.IsPlaying then + leds[e.Name].Color = Color3.new(1,1,0) + ready = false + else + leds[e.Name].Color = Color3.new(0,1,0) + end + end + else + ready = false + end + wait() + end +end +function togglePTT() + print("toggling ptt") + if ptt then + ptt = false + print("off") + thisTimeout = nil + for i,e in pairs(selectedZones) do + task.spawn(function() + toggleZone(e.Name) + local thisTone = tones[zones[e.Name].EndTone.Value] + zones[e.Name].ZoneInput.Wire.SourceInstance = thisTone + thisTone:Play() + wait(thisTone.TimeLength) + zones[e.Name].ZoneInput.Wire.SourceInstance = nil + smoothTransition(zones[e.Name].BGM.Volume,script.Parent.BGMUp.Value, 1, function(value) + zones[e.Name].BGM.Volume = value + end) + end) + end + else + local ready = false + for i,e in pairs(selectedZones) do + ready = true + print("we have a zone, continue") + end + if not ready then return end + ptt = true + for i,e in pairs(selectedZones) do + task.spawn(function() + local thisTone = tones[zones[e.Name].PageTone.Value] + waiting = true + smoothTransition(zones[e.Name].BGM.Volume, script.Parent.BGMDown.Value, 1, function(value) + zones[e.Name].BGM.Volume = value + end) + waiting = false + zones[e.Name].ZoneInput.Wire.SourceInstance = thisTone + thisTone:Play() + wait(thisTone.TimeLength) + if(ptt) then + -- We havent stopped PTT before page tone done, hit it + zones[e.Name].ZoneInput.Wire.SourceInstance = script.Parent.StationOutput + thisTimeout = math.random(1,1000000) + task.spawn(function() + local myTimeout = tonumber(tostring(thisTimeout)) + wait(script.Parent.TimeoutSeconds.Value) + if myTimeout == thisTimeout then + togglePTT() + end + end) + end + end) + end + end + +end + + +for i,e in ipairs(script.Parent.Buttons:GetChildren()) do + buttons[e.Name] = e + print("Adding button " .. e.Name) + e.CD.MouseClick:Connect(function() + toggleZone(e.Name) + print("button pressed " .. e.Name) + end) +end + +pttButton.MouseClick:Connect(function() + togglePTT() +end) + +for i,e in ipairs(script.Parent.Buttons:GetChildren()) do + leds[e.Name] = e +end + +for i,e in ipairs(system.Zones:GetChildren()) do + zones[e.Name] = e +end + +for i,e in ipairs(system.Tones:GetChildren()) do + tones[e.Name] = e +end + +task.spawn(checkZones) +task.spawn(flashSelected) +task.spawn(checkReady) \ No newline at end of file diff --git a/Scripts/SeparateLEDsStation.lua b/Scripts/SeparateLEDsStation.lua new file mode 100644 index 0000000..e1c7f54 --- /dev/null +++ b/Scripts/SeparateLEDsStation.lua @@ -0,0 +1,221 @@ +local system = script.Parent.Parent.Parent +local zones = {} +local mic = script.Parent["Panel Mic"].mic.AudioListener +local buttons = {} +local leds = {} +local ptt = false +pttButton = script.Parent["Panel Mic"].mic.CD +local selectedZones = {} +local tones = {} +local thisTimeout = nil +local TweenService = game:GetService("TweenService") +local waiting = false +function smoothTransition(startValue, endValue, duration, updateFunction) + local finished = false + -- Create a temporary NumberValue to tween + local numberValue = Instance.new("NumberValue") + numberValue.Value = startValue + + -- Create TweenInfo + local tweenInfo = TweenInfo.new( + duration, -- Duration of the tween + Enum.EasingStyle.Linear, -- Easing style + Enum.EasingDirection.InOut, -- Easing direction + 0, -- Number of times to repeat + false, -- Whether to reverse the tween + 0 -- Delay time before starting the tween + ) + + -- Create tween goal + local tweenGoal = {Value = endValue} + + -- Create the tween + local tween = TweenService:Create(numberValue, tweenInfo, tweenGoal) + + -- Connect the update function to the Changed event + local connection + connection = numberValue.Changed:Connect(function() + -- Call the update function with the current value + updateFunction(numberValue.Value) + end) + + -- Play the tween + tween:Play() + + -- Cleanup after tween completes + tween.Completed:Connect(function() + -- Ensure the final value is set to endValue + updateFunction(endValue) + -- Disconnect the event and remove the NumberValue instance + connection:Disconnect() + numberValue:Destroy() + finished = true + end) + repeat wait() until finished + finished = false +end + +function toggleZone(zoneNumber) + if ptt then return end -- We're transmitting, don't toggle zones + if selectedZones[zoneNumber] then + selectedZones[zoneNumber] = nil + leds[zoneNumber].Color = Color3.new(202/255, 203/255, 209/255) + leds[zoneNumber].Material = Enum.Material.SmoothPlastic + else + if zones[zoneNumber].ZoneInput.Wire.Connected then + -- Nothing, in use + else + selectedZones[zoneNumber] = zones[zoneNumber] + end + end +end + +function flashSelected() + local state = false + while true do + while not ptt do + for i,e in pairs(selectedZones) do + if state then + leds[i].Material = Enum.Material.SmoothPlastic + leds[i].Color = Color3.new(202/255, 203/255, 209/255) + else + leds[i].Material = Enum.Material.Neon + leds[i].Color = Color3.new(1,1,0) + end + end + state = not state + wait(.2) + end + wait() + end +end + +function checkZones() + while true do + for i,e in pairs(leds) do + if not selectedZones[e.Name] then + if zones[e.Name].ZoneInput.Wire.Connected then + e.Material = Enum.Material.Neon + e.Color = Color3.new(1,0,0) + else + e.Material = Enum.Material.SmoothPlastic + e.Color = Color3.new(202/255, 203/255, 209/255) + end + elseif not ptt and selectedZones[e.Name] and zones[e.Name].ZoneInput.Wire.Connected then + -- Someone else took the zone, drop it from selections + toggleZone(e.Name) + end + end + wait(0) + end +end +function checkReady() + local ready = true + while true do + if ptt then + ready = true + for i,e in pairs(selectedZones) do + print("checking " .. e.Name) + leds[e.Name].Material = Enum.Material.Neon + local thisTone = tones[e.PageTone.Value] + if thisTone.TimeLength == 0 then + -- Empty audio, stop playing it + thisTone:Stop() + end + if waiting or thisTone.IsPlaying then + leds[e.Name].Color = Color3.new(1,1,0) + ready = false + else + leds[e.Name].Color = Color3.new(0,1,0) + end + end + else + ready = false + end + wait() + end +end +function togglePTT() + print("toggling ptt") + if ptt then + ptt = false + print("off") + thisTimeout = nil + for i,e in pairs(selectedZones) do + task.spawn(function() + local thisTone = tones[zones[e.Name].EndTone.Value] + zones[e.Name].ZoneInput.Wire.SourceInstance = thisTone + thisTone:Play() + wait(thisTone.TimeLength) + zones[e.Name].ZoneInput.Wire.SourceInstance = nil + smoothTransition(zones[e.Name].BGM.Volume,script.Parent.BGMUp.Value, 1, function(value) + zones[e.Name].BGM.Volume = value + end) + end) + end + else + local ready = false + for i,e in pairs(selectedZones) do + ready = true + print("we have a zone, continue") + end + if not ready then return end + ptt = true + for i,e in pairs(selectedZones) do + task.spawn(function() + local thisTone = tones[zones[e.Name].PageTone.Value] + waiting = true + smoothTransition(zones[e.Name].BGM.Volume, script.Parent.BGMDown.Value, 1, function(value) + zones[e.Name].BGM.Volume = value + end) + waiting = false + zones[e.Name].ZoneInput.Wire.SourceInstance = thisTone + thisTone:Play() + wait(thisTone.TimeLength) + if(ptt) then + -- We havent stopped PTT before page tone done, hit it + zones[e.Name].ZoneInput.Wire.SourceInstance = script.Parent.StationOutput + thisTimeout = math.random(1,1000000) + task.spawn(function() + local myTimeout = tonumber(tostring(thisTimeout)) + wait(script.Parent.TimeoutSeconds.Value) + if myTimeout == thisTimeout then + togglePTT() + end + end) + end + end) + end + end + +end + + +for i,e in ipairs(script.Parent.Buttons:GetChildren()) do + buttons[e.Name] = e + print("Adding button " .. e.Name) + e.CD.MouseClick:Connect(function() + toggleZone(e.Name) + print("button pressed " .. e.Name) + end) +end + +pttButton.MouseClick:Connect(function() + togglePTT() +end) + +for i,e in ipairs(script.Parent.Leds:GetChildren()) do + leds[e.Name] = e +end + +for i,e in ipairs(system.Zones:GetChildren()) do + zones[e.Name] = e +end + +for i,e in ipairs(system.Tones:GetChildren()) do + tones[e.Name] = e +end + +task.spawn(checkZones) +task.spawn(flashSelected) +task.spawn(checkReady) \ No newline at end of file diff --git a/Scripts/SingleStation.lua b/Scripts/SingleStation.lua new file mode 100644 index 0000000..cc4ac67 --- /dev/null +++ b/Scripts/SingleStation.lua @@ -0,0 +1,152 @@ +local system = script.Parent.Parent.Parent +local mic = script.Parent.WallMic["Mic Enclosure"].AudioListener +local buttons = {} +local led = script.Parent.LED +local ptt = false +pttButton = script.Parent.WallMic["Mic Enclosure"].CD +local zones = {} +local tones = {} +local thisTimeout = nil +local TweenService = game:GetService("TweenService") +local waiting = false + +function smoothTransition(startValue, endValue, duration, updateFunction) + local finished = false + -- Create a temporary NumberValue to tween + local numberValue = Instance.new("NumberValue") + numberValue.Value = startValue + + -- Create TweenInfo + local tweenInfo = TweenInfo.new( + duration, -- Duration of the tween + Enum.EasingStyle.Linear, -- Easing style + Enum.EasingDirection.InOut, -- Easing direction + 0, -- Number of times to repeat + false, -- Whether to reverse the tween + 0 -- Delay time before starting the tween + ) + + -- Create tween goal + local tweenGoal = {Value = endValue} + + -- Create the tween + local tween = TweenService:Create(numberValue, tweenInfo, tweenGoal) + + -- Connect the update function to the Changed event + local connection + connection = numberValue.Changed:Connect(function() + -- Call the update function with the current value + updateFunction(numberValue.Value) + end) + + -- Play the tween + tween:Play() + + -- Cleanup after tween completes + tween.Completed:Connect(function() + -- Ensure the final value is set to endValue + updateFunction(endValue) + -- Disconnect the event and remove the NumberValue instance + connection:Disconnect() + numberValue:Destroy() + finished = true + end) + repeat wait() until finished + finished = false +end + +for i, e in ipairs(system.Tones:GetChildren()) do tones[e.Name] = e end +for i, e in ipairs(system.Zones:GetChildren()) do zones[e.Name] = e end +local zone = zones[script.Parent.Zone.Value] + +function checkZones() + while true do + if zone.ZoneInput.Wire.Connected and not ptt then + led.Material = Enum.Material.Neon + led.Color = Color3.new(1, 0, 0) + elseif not ptt then + led.Material = Enum.Material.SmoothPlastic + led.Color = Color3.new(163/255, 162/255, 165/255) + end + wait(0) + end +end +function checkReady() + local ready = true + while true do + if ptt then + ready = true + + -- print("checking " .. zone) + led.Material = Enum.Material.Neon + local thisTone = tones[zone.PageTone.Value] + if thisTone.TimeLength == 0 then + -- Empty audio, stop playing it + thisTone:Stop() + end + if waiting or thisTone.IsPlaying then + led.Color = Color3.new(1, 1, 0) + ready = false + else + led.Color = Color3.new(0, 1, 0) + end + else + ready = false + end + wait() + end +end + + + +function togglePTT() + + -- print("toggling ptt") + if ptt then + ptt = false + thisTimeout = nil + -- print("off") + task.spawn(function() + local thisTone = tones[zone.EndTone.Value] + zone.ZoneInput.Wire.SourceInstance = thisTone + thisTone:Play() + wait(thisTone.TimeLength) + zone.ZoneInput.Wire.SourceInstance = nil + smoothTransition(zone.BGM.Volume, script.Parent.BGMUp.Value, 1, function(value) + zone.BGM.Volume = value + end) + end) + else + if zone.ZoneInput.Wire.Connected then return end + ptt = true + task.spawn(function() + local thisTone = tones[zone.PageTone.Value] + waiting = true + smoothTransition(zone.BGM.Volume, script.Parent.BGMDown.Value, 1, function(value) + zone.BGM.Volume = value + end) + waiting = false + zone.ZoneInput.Wire.SourceInstance = thisTone + thisTone:Play() + wait(thisTone.TimeLength) + if (ptt) then + -- We havent stopped PTT before page tone done, hit it + zone.ZoneInput.Wire.SourceInstance = script.Parent.StationOutput + thisTimeout = math.random(1, 1000000) + task.spawn(function() + local myTimeout = tonumber(tostring(thisTimeout)) + wait(script.Parent.TimeoutSeconds.Value) + if myTimeout == thisTimeout then + togglePTT() + end + end) + end + end) + end + +end + +pttButton.MouseClick:Connect(function() togglePTT() end) + +task.spawn(checkReady) +task.spawn(checkZones) \ No newline at end of file