Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why does my music button only play to the person playing the music?

I made a part so that when you click on it, a gui shows up with a play button, a stop button, and a textbox to put the text in. The sound is inside the part that you click. The gui is in PlayerGui. But whenever I play the song, it only plays for myself, and not any other players. How do I fix this

ClickDetector script

	script.Parent.ClickDetector.MouseClick:Connect(function(player)
			player:WaitForChild("PlayerGui").StudioFMusic.Frame.Visible = true
	end)


Button that closes the gui

script.Parent.MouseButton1Click:Connect(function(player)
		script.Parent.Parent.Visible = false
	end)


Play Button.

script.Parent.MouseButton1Click:connect(function()
	local text = script.Parent.Parent.TextBox.Text
	local sound = game.Workspace.StudioFMusic.PlayableSound
								sound.SoundId = 'rbxassetid://'..text
								sound:Play()
end)

Stop Button

script.Parent.MouseButton1Click:connect(function()
	local sound = game.Workspace.StudioFMusic.PlayableSound
	sound:Stop()
	end)

The stop button, and play button are local scripts, the rest are normal scripts.

2 answers

Hey Catherine,

You're playing the sound locally and therefore it'll only play on that local client regardless of where it is.

You can get around this by turning off "RespectFilteringEnabled" in the "SoundService" directory in game.

Good luck.

Mateyz

3 comments

0

I tried turning that off, but it's still not playing for others.

0

So the other thing that I'd do is to "RespectFilteringEnabled" true and then just use a remoteEvent to play it.

0

I don't really have much experience with remoteevents. Can you explain how I can use it?

So, to achieve server-sided music playback (so everyone will hear it) you will have to use RemoteEvents

Replace the play button script with this

local PlayButton = script.Parent

PlayButton.MouseButton1Click:Connect(function()
	local text = script.Parent.Parent.TextBox.Text
	game.ReplicatedStorage.MusicPlay:FireServer("Play",text)
end)

Replace the Stop Button's script to

local StopButton = script.Parent

StopButton.MouseButton1Click:connect(function()
	game.ReplicatedStorage.MusicPlay:FireServer("Stop")
end)

After that, Create a new RemoteEvent in ReplicatedStorage Called MusicPlay

And create a new script (you choose name) and parent it in ServerScriptService

Paste this into the script:

local sound = game.Workspace.StudioFMusic.PlayableSound

game.ReplicatedStorage.MusicPlay.OnServerEvent:Connect(function(plr,choice,id)
	if choice == "Play" then
		if id then
			sound.SoundId = "rbxassetid://"..id
			sound:Play()
		end
	elseif choice == "Stop" then
		sound:Stop()
	end
end)

And that should work! Good luck with the game!!

3 comments

0

dang why the bacons smarter than me :(

0

Triggered

0

Bacons are secretly nerds..

This discussion is preserved as it was. New answers, comments, and votes are closed.