I’m stuck on scripting this. Whenever I try to do it the music overlaps at some point. I have an bool value which controls when it’s considered “the round” and when not.
Can someone teach me how to implement this in a good way?
I’m stuck on scripting this. Whenever I try to do it the music overlaps at some point. I have an bool value which controls when it’s considered “the round” and when not.
Can someone teach me how to implement this in a good way?
Use the :GetPropertyChangedSignal() function of the value instance, when it changes, check if the value is true or false, if its true, :Stop() the lobby music, and :Play() the round music (or other way around depending on how you prefer it)
Sound:GetPropertyChangedSignal(“Playing”) would be a good use.
He said he has a bool value - therefore :GetPropertyChangedSignal(“Value”)
Yes, but he could detect when one sound stops playing to play the other without overlapping issues, just another method.
Thanks.
he wants it to change when the round starts/ends, not when the song happens to finish.
Here’s my code. For some reason the lobby music doesn’t stop playing when IsGame’s value is true
local lobby_id = {"rbxassetid://8826039959", -- Leaving The Solar System
"rbxassetid://8074436435" -- Pixel Peeker Polka
}
local round_id = {"rbxassetid://3838068678" -- Unsafe Speeds
}
local lobby_music = workspace.Music["Lobby music"]
local round_music = workspace.Music["Round music"]
local IsGame = game.ReplicatedStorage.IsGame
IsGame:GetPropertyChangedSignal("Value")
if IsGame.Value then
lobby_music:Stop()
local chosen_round_music = round_id[math.random(1,#round_id)]
round_music.SoundId = chosen_round_music
round_music:Play()
else
round_music:Stop()
local chosen_lobby_music = lobby_id[math.random(1,#lobby_id)]
lobby_music.SoundId = chosen_lobby_music
lobby_music:Play()
end
You have to add a connect, like so:
local lobby_id = {"rbxassetid://8826039959", -- Leaving The Solar System
"rbxassetid://8074436435" -- Pixel Peeker Polka
}
local round_id = {"rbxassetid://3838068678" -- Unsafe Speeds
}
local lobby_music = workspace.Music["Lobby music"]
local round_music = workspace.Music["Round music"]
local IsGame = game.ReplicatedStorage.IsGame
IsGame:GetPropertyChangedSignal("Value"):Connect(function()
if IsGame.Value then
lobby_music:Stop()
local chosen_round_music = round_id[math.random(1,#round_id)]
round_music.SoundId = chosen_round_music
round_music:Play()
else
round_music:Stop()
local chosen_lobby_music = lobby_id[math.random(1,#lobby_id)]
lobby_music.SoundId = chosen_lobby_music
lobby_music:Play()
end
end)
Thanks for pointing that out for me
Yes, but he can use that to check if the sound is still playing. I’m not going to argue.
But it was just another method he could use.