Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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.

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 Player1_Joined 271 — 4y
0
Could you give me an example? julianhak06 12 — 4y

1 answer

Log in to vote
0
Answered by
sngnn 274 Moderation Voter
4 years ago
Edited 4 years ago

"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)
0
Thanks, i'll try to build the script from there. julianhak06 12 — 4y
Ad

Answer this question