Hello! I recently learned remote events and was going to make something liks custom music. It works correctly, but I still don’t understand how to set up stopping or playing music when client changes id of sound. I didn’t find anything about it, so I’m asking for help here.
Here is something I wrote:
local event = game:GetService("ReplicatedStorage").RemoteEvent
local sound = game.Workspace.Sound
event.OnServerEvent:Connect(function(player, idsound)
sound.SoundId = 'rbxassetid://'..idsound
end)
local event = game:GetService("ReplicatedStorage").RemoteEvent
local sound = workspace.Sound -- You can also use "game.Workspace"
event.OnServerEvent:Connect(function(player, idsound)
sound:Stop() -- Makes the sound stop playing music
sound.SoundId = 'rbxassetid://'..idsound -- Insert this if you want to change music
end)
Then you can insert the line below to play the music
sound:Play()
Hope it helps!
Ps: Sorry for the bad english, I’m italian