How, and even can I return a value from RemoteEvent?

For example, I want to grab a player's leaderstat value in Script.

`Script`:
game.ReplicatedStorage.GetWord:FireClient(plr)

and then:

`LocalScript`:
game.ReplicatedStorage.GetWord.OnClientEvent:Connect(function()
	return "Hello world!"
end)

Then, in Script, print (GetWord) should print "Hello World", because that's what Local is returning. Can it be done like this?

Also: tip for other-language programmers: That should look like (in Java):

public static void getWord(){
	return "Hellow world!"
}

in another class:

System.out.println(getWord())

5 comments

0

No, (unless resending the remote); but you can however use remote functions, which are exactly made for that

0

Okay so how? Explain Remote Functions then, never used them..

0

conceptually, they are very similar but instead of FireServer you use InvokeServer and instead of OnServerEvent use OnServerInvoke, vice versa, but you cant connect a function to it, instead assign it, then return whatever values you wish, it also yields the thread it was invoked from

0

Thanks, real helpful. Also, why not a answer? I could accept it and we would be both happy :P