Hello !
Trying to make a local Radio GUI with preset sounds, currently script is not finished yet the sound starts but I can’t stop/pause the sounds in this state, I am not sure which point is wrong, I have tried several more ways such as using sounds[position]:Play() or Resume() and sounds[position]:Stop() or Pause() as well, the script looks like returning the Print commands I write to the top and bottom of sounds[position]:Stop / :Pause() commands however it does not stop.
Here is the code of the Radio ;
local sound1 = script.sd1
local sound2 = script.sd2
local sound3 = script.sd3
local sound4 = script.sd4
local sound5 = script.sd5
local sound6 = script.sd6
local sound7 = script.sd7
local sound8 = script.sd8
local sound9 = script.sd9
local Menu = script.Parent.Menu
local PlayButton = Menu.Play
local SongLabel = Menu.SongName
local SongVolume = Menu.SongVol
local LastSong = Menu.LastS
local NextSong = Menu.NextS
local LoopToggle = Menu.LoopS
local CurrentSound = false
local currentTime = 60
local sounds = {sound1, sound2, sound3, sound4, sound5, sound6, sound7, sound8}
nsound1 = "Test1"
nsound2 = "Test2"
nsound3 = "Test3"
nsound4 = "Test4"
nsound5 = "Test5"
nsound6 = "Test6"
nsound7 = "Test7"
nsound8 = "Test8"
nsound9 = "Test9"
local toggle = false
local position = 1
local repea = false
PlayButton.MouseButton1Click:Connect(function()
print("PlaybuttenConnect")
if toggle == false then
toggle = true
sounds[position].Playing = true
print(sounds[position])
while toggle == true do
repeat wait(1) until currentTime == 0
print ("Waited")
position = position + 1
if position >= #sounds then
position = 1
end
sounds[position].Playing = true
end
elseif toggle == true then
toggle = false
print(sounds[position])
sounds[position].Playing = false
end
print(toggle)
end)
sounds[position].IsPlaying:Connect(function()
if position == sound1 then
currentTime = sound1.TimeLength
elseif position == sound2 then
currentTime = sound2.TimeLength
elseif position == sound3 then
currentTime = sound3.TimeLength
elseif position == sound4 then
currentTime = sound4.TimeLength
elseif position == sound5 then
currentTime = sound5.TimeLength
elseif position == sound6 then
currentTime = sound6.TimeLength
elseif position == sound7 then
currentTime = sound7.TimeLength
elseif position == sound8 then
currentTime = sound8.TimeLength
elseif position == sound9 then
currentTime = sound9.TimeLength
end
repeat wait(1 )until currentTime == 0 do
currentTime = currentTime - 1
end
end)
LoopToggle.MouseButton1Click:Connect(function()
print("LoopbuttonConnect")
if repea == false then
repea = true
sounds[position].Looped = true
elseif repea == true then
repea = false
sounds[position].Looped = false
end
print(repea)
end)
Any help would be great