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

When to use remote event or remote function?

I've never really understood when I should use remote events over remote functions or the other way around. I always use remote events and never have used remote functions, should I be using them for certain things?

1 comment

0

If you want a value returned then you'll want to use a remote function, otherwise just stick to events

2 answers

✓ Accepted answer

Let's say you use remote events when you want something to run in another script that's not on the same type of script as the one you fire it from.

You use a remote function when you need a value returned by the function, a practical example:

localscript:

local remfunction = game.ReplicatedStorage.RemoteFunction

print(remfunction:InvokeServer())

script:

local x = "potato"
local remfunction = game.ReplicatedStorage.RemoteFunction

local function returnpotato()
	return x
end

remfunction.OnServerInvoke = returnpotato()

The local script in the above example would print "potato".

1 comment

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