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

How would one use Remote Events/Functions?

Asked by 9 years ago

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

Log in to vote
1
Answered by
yumtaste 476 Moderation Voter
9 years ago

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.

0
What dose return do again? Wiki never explained that either. Dose it just update the variable? Orlando777 315 — 9y
0
Return does exactly what it sounds like. I'll add an explanation in my answer yumtaste 476 — 9y
0
Where dose it return the value? To the orinal parameter? Orlando777 315 — 9y
0
What? yumtaste 476 — 9y
View all comments (4 more)
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. Orlando777 315 — 9y
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 yumtaste 476 — 9y
0
If you can that would be great, thanks for the help. Orlando777 315 — 9y
0
Ok. I'll do that first thing in the morning. If you could also give me an upvote, that'd be nice. yumtaste 476 — 9y
Ad

Answer this question