Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

2 answers

✓ Accepted answer

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

-- Server Script
rf = Instance.new("RemoteFunction", workspace)
rf.Name = "GetPlayerName"
-- Client Script
rf = workspace:WaitForChild("GetPlayerName")
rf.OnClientInvoke = function() -- Callback function
	return game.Players.LocalPlayer.Name
end
-- Other Server Script
print(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:

-- Server Script
re = Instance.new("RemoteEvent", workspace)
re.Name = "PlaceBlock"
re.OnServerEvent:Connect(function(pos)
	if pos ~= nil then
		part = Instance.new("Part", workspace)
		part.Position = pos
	end
end)
-- Client Script
workspace.PlaceBlock:FireServer() -- Returns nothing, but places a block on the server even with FE.

Hope that helps!

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.