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