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

When to use remote events and remote functions?

Asked by
Jumbuu 110
8 years ago

i plan on using filtering enabled and i was wondering in what cases would i HAVE to use remote events and functions?

2
You only need to use remote events and functions when you want to communicate between the client and server (between scripts and localscripts). For instance, change a brick color then change a gui. You'd either need to call an event from the client to change the brick color, or call the event from the server to change the gui. GoldenPhysics 474 — 8y
0
This deserves to be an answer. Link150 1355 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

Use RemoteEvents and RemoteFunctions when you want to change something on the server from the client or change something on the client from the server. You'd need to do this because with Filtering enabled, you are unable to edit the server. To set up RemoteEvents, you'd have to have a script on your server. After that, put a LocalScript in StarterGui. Then, you'd have to put a remote somewhere (perferably ReplicatedStorage). Now let's say you wanted to anchor your torso from the client. To do this, you'd have to type this into the script on the server: remote.OnServerEvent:connect(function(sender, victim) workspace[victim].Torso.Anchored = true end This requires two parameters. The first is automatically set. I put it as 'sender' but it is who is firing the event. The next is the victim that will have its torso anchored. Now that we've done that, let's move into our local script in StarterGui. You now need to fire the event, so to do this we'll do FireServer. An example of that, which would anchor the players torso in our case, would be remote:FireServer(game.Players.LocalPlayer.Name) You might notice, the function had two parameters. Well like I said, the first is automatically set, and would be your LocalPlayer.

Finally, test the game.

Sorry if this wasn't the best it could be, I'm on my phone right now and it's hard to type (because I just cracked my screen super badly)

Ad

Answer this question