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

How do I make this sound board play sounds for everyone?

So, I want to include voice lines in my game (it's a Star Wars game), so, to take audio from Star Wars, and allow people to play it in order to communicate. Give orders, or just in general have fun with it. The only script I could really think of is:

script.Parent.MouseButton1Click:Connect(function()
	--Fire sound
	script.Parent.Sound:Play()
end)

But, i've had no luck. Any help is appreciated.

2 comments

0

You would want to use RemoteEvents, they're very helpful in times like this. If you need more info on using them this should help: https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events

0

Could you give me an example?

1 answer

✓ Accepted answer

"Could you give me an example?" Yes!

RemoteEvents are a way to send information from the client to the server, or the server to the client. You can send information by doing one of these three:

--All of these functions are a member of the event itself, not the script.
RemoteEvent:FireServer(stuff)
RemoteEvent:FireClient(plr,stuff)
RemoteEvent:FireAllClients(stuff)

And you can get the information by:

--Again, a member of the event.
RemoteEvent.OnServerEvent:Connect(function(plr,stuff)
RemoteEvent.OnClientEvent:Connect(function(stuff)

So, you would do something like:

LocalScript:

local event = location.RemoteEvent

script.Parent.MouseButton1Click:Connect(function()
	event:FireServer(script.Parent)
end)

Server script:

local event = location.RemoteEvent --getting the same event

event.OnServerEvent:Connect(function(plr,sound) --"plr" is the player, which is always included inside of this event
	sound:Play()
end)

1 comment

0

Thanks, i'll try to build the script from there.

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