I'm trying to make an event occur in my game that happens every 100 seconds that changes the music to another sound which is different from the normal background music.
Then the event is supposed to go for 20 seconds and then revert back to the normal background music.
Below is my script and I am bad at scripting and want to know what I did wrong.
local music = game.SoundService.Buttercup --normal song playing in background
local sound = game.SoundService.Party --event song
d = 1 --for a true statement
while d == 1 do
wait(100) --every 100 seconds event plays
music:Stop()
sound:Play()
wait(20) --event plays for 20 seconds
sound:Stop()
music:Play()
end

3 comments
Why not just do
while true doinstead of == true do. Remove the entire variable@Ha_rriz I think you may have misunderstood. I want to wait 100 seconds between events, but it looks like with this it would play right away and then play for 100 seconds. I put notes on the side to say what I was going for.
Also a sidenote is that there is already music playing the background when you spawn in and when the event happens I want the sound to go away and play the event music for 20 seconds then back to normal background music.