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)
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…
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)
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)
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.
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
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