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

How does the remote event work here?

Asked by 5 years ago

I'm not sure about this but I have a GUI button that functions locally and uses a remote event to enable some scripts in the player's character. The thing is that there is only one remote event and so every player that presses the button would fire the same event to change their own scripts in their character. I'm not sure if this even is the right way to do it.

Well, the thing that I'm really confused about is that what if multiple players press the button at almost the same time. Will the server script that listens for the event be able to do whatever it needs to do for all those players?

--Script

local event = Instance.new("RemoteEvent")
event.Parent = game.ReplicatedStorage
event.Name = "Event"

event.OnServerEvent:connect(function(player)
    player.Character.FallDamageScript.Disabled = false
end)

--Local script

script.Parent.MouseButton1Down:connect(function()
    game.ReplicatedStorage:WaitForChild("Event"):FireServer()
end)

Or maybe are there other ways to do this actually? I could maybe have a script that creates a remote event for every specific player that joins. Or wait can I actually create the remote event from the local script itself? I'm really quite confused now and I've got more ideas for this that I'm not sure about.

1 answer

Log in to vote
0
Answered by
LeadRDRK 437 Moderation Voter
5 years ago

Yes, this is correct. You might want to add a debounce tho, since there's a bandwith limit on remote events (and functions)

0
Wait so that means that if many players click the button almost at once, it would be able to still function properly? Inscendio 42 — 5y
0
Yes. LeadRDRK 437 — 5y
Ad

Answer this question