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

How would one use Remote Events/Functions?

Due to Filtering Enabled I want to use remote events/functions, but the wiki does a poor job explaining things ever since they updated it. Could anyone give me examples of scenarios between client/server communication when it would be needed?

1 answer

✓ Accepted answer

I can't really think of a logical scenario for this.

--in the LocalScript
local RemoteFunction = --insert RemoteFunction hierarchy here
print(RemoteFunction:InvokeServer("bar")
--end of LocalScript

--in a normal server script
local RemoteFunction = --insert RemoteFunction hierarchy here
function RemoteFunction.OnServerInvoke(variable)
print("foo"..variable)
return "foobar :D"
end
--end of server script

Output:

LocalScript foobar :D Script foobar

Basically, the LocalScript gives the Script a part of the word "foobar," and the Script prints its part of the word along with the LocalScript's part of the word, to form the whole word. The LocalScript then prints the result that the Script gave it.

EDIT: Return does exactly what it sounds like. It returns objects from a function.

function returnText()
return "hello!"
end

print(returnText) --prints "hello!"

RemoteEvents do the same thing as RemoteFunctions, just RemoteEvents don't return anything, minimizing latency. So basically, RemoteEvents just allow communications between LocalScripts and server Scripts, and vice versa.

8 comments

0

What dose return do again? Wiki never explained that either. Dose it just update the variable?

0

Return does exactly what it sounds like. I'll add an explanation in my answer

0

Where dose it return the value? To the orinal parameter?

0

What?

0

I guess my question is what object? You mean the variable right? Btw, I didn't really understand your remote function example. Maybe something with parts? Not just a print function.

0

Yeah. You can substitute the strings for parts if you want. If you don't know how to do that I can put in another edit

0

If you can that would be great, thanks for the help.

0

Ok. I'll do that first thing in the morning. If you could also give me an upvote, that'd be nice.

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