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

remote function or remote events. when to use which one?

Asked by 7 years ago

whats the main difference from remote functions and remote events? when is approppiate to use either?

2 answers

Log in to vote
0
Answered by 7 years ago

Say you wanted to get a value of the client while using FE, you would make a script like:

01-- Server Script
02rf = Instance.new("RemoteFunction", workspace)
03rf.Name = "GetPlayerName"
04-- Client Script
05rf = workspace:WaitForChild("GetPlayerName")
06rf.OnClientInvoke = function() -- Callback function
07    return game.Players.LocalPlayer.Name
08end
09-- Other Server Script
10print(workspace.GetPlayerName:InvokeClient(game.Players.SebbyTheGODKid))

That will print "SebbyTheGODKid"

But say you JUST wanted to use a remote event to place a block from the client:

01-- Server Script
02re = Instance.new("RemoteEvent", workspace)
03re.Name = "PlaceBlock"
04re.OnServerEvent:Connect(function(pos)
05    if pos ~= nil then
06        part = Instance.new("Part", workspace)
07        part.Position = pos
08    end
09end)
10-- Client Script
11workspace.PlaceBlock:FireServer() -- Returns nothing, but places a block on the server even with FE.

Hope that helps!

Ad
Log in to vote
0
Answered by 7 years ago

Straight from roblox forum.

"The first difference is that RemoteFunctions are designed for two way communication, while RemoteEvents are designed for one way. A RemoteFunction sends a request and then waits for a response, while RemoteEvents just send a request."

For a better description, you can go on the forum itself.

Link: http://wiki.roblox.com/index.php?title=Remote_Events_and_Functions

I dont really know the difference myself, so I just used the wiki, lmao.

Answer this question