SoundGui Problem

Hello guys I’m creating a music system, the player has a Gui with a TextBox and when he clicks play all the other players can hear the song. I did all right, I think, but don’t know why in the Roblox Studio Test Server (with two dummies) only the player who plays the sound can hear it and other one no.

  • Inside the GUI there all the assets: Server Script, Local Script and the Remote Event
  • The Sound instance is located inside the HumanoidRootPart, cause all the player can Play their Songs

PS: I already used this kind of system to play something, and all was good , but now not

  • Server Script:
local PlayEvent = script.Parent.PlayEvent


PlayEvent.OnServerEvent:Connect(function(Player)
	local Music = Player.Character:WaitForChild("HumanoidRootPart"):WaitForChild("Music")
	
		Music:Play()
end)
  • LocalScript
local PlayEvent = script.Parent.PlayEvent

local Container = script.Parent
local PlayButton = Container.PlayButton 


PlayButton.MouseButton1Click:Connect(function()
	PlayEvent:FireServer()
end)
2 Likes

I can’t find any problems with your script.

It could be because you’re using dummies and not real players, but I’m not sure. Any errors in the output?

1 Like

no any error occurred, I also tried using players, but nothing it doesn’t work.
I think that this issue is no sense cause the Sound is inside the player character in the workspace, and also it’s activated using a Server Script…

1 Like

Okay, try this. Move your server script to ServerScriptService and name it “MusicServer” for better accessibility. Move your PlayEvent to ReplicatedStorage and name it “MusicEvent”.

Here’s what the updated Server script should look like:

local musicEvent = game.ReplicatedStorage:WaitForChild("MusicEvent")

musicEvent.OnServerEvent:Connect(function(Player)
    local character = Player.Character or Player.CharacterAdded:Wait()
	local Music = character:WaitForChild("HumanoidRootPart"):WaitForChild("Music")
	Music:Play()
end)

And here’s what the updated LocalScript should look like. Keep it in the GUI and name it “ClientMusicHandler” for better accessibility.

local musicEvent = game.ReplicatedStorage:WaitForChild("MusicEvent")

local frame = script.Parent
local btn = frame:WaitForChild("PlayButton")

btn.MouseButton1Click:Connect(function()
	PlayEvent:FireServer()
end)
1 Like

i have an idea

what if its because the music is not directly plugged in from the game and since you may be using an external audio ID it will only work (as in play) for the creators or shared developers (depending if its a group game or not)

2 Likes

That’s true.

Your script seems fine, and the changes I suggested don’t really affect much. It could be that your experience doesn’t have the necessary permissions to play the audio.

1 Like

umh, maybe it’s possible but I tried to put a part inside the workspace and inside of it a Sound with the same Audio, just to try and it runs. I mean that my two accounts were be able to hear it

1 Like

Okay, then try doing what I said in the previous post.

1 Like

Nothing, it doesn’t run I also tried to see if there was any error but nothing, all’s good
I use this code (in a server Script) to create the Sound istance

game.Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(char)
		local Sound = Instance.new("Sound", char:WaitForChild("HumanoidRootPart"))
		Sound.Name = "Music"
		Sound.Looped = true
	end)
end)

Play the sound, you’re not playing it in the script