Song plays for client but not server

So I’ve been trying to make a radio that can have the song changed by clicking on it in the Workspace by accessing a GUI. The song changes for the player’s client and plays, but does not play for the server. There are no errors showing up in the output.

Local Script:


local textbox = script.Parent.Parent:WaitForChild("TextBox")
local sound = game.Workspace.Radio:WaitForChild("Sound")

script.Parent.MouseButton1Click:Connect(function()
	sound.SoundId = "rbxassetid://"..textbox.Text
	game.ReplicatedStorage.PlayMusic:FireServer()
end)


Script:


game.ReplicatedStorage.PlayMusic.OnServerEvent:Connect(function()
	game.Workspace.Radio.Sound:Play()
end)
1 Like

You’re chaning the SoundID locally. To fix that, make the following edits that I’m going to explain to you.

LocalScript:

local textbox = script.Parent.Parent:WaitForChild("TextBox")
local sound = game.Workspace.Radio:WaitForChild("Sound")

script.Parent.MouseButton1Click:Connect(function()
	local SoundID = "rbxassetid://"..textbox.Text --Make a variable containing the SoundID
	game.ReplicatedStorage.PlayMusic:FireServer(SoundID) --Send the SoundID to the server
end)

And the ServerScript:

game.ReplicatedStorage.PlayMusic.OnServerEvent:Connect(function(Player, SoundID) --Receive the call

	game.Workspace.Radio.SoundId = SoundID --Use our SoundId sent by the client
       game.Workspace.Radio:Play()
end)

Hope that helps you out!

2 Likes