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

Can I return a value in RemoteEvent?

Asked by
NorteX_tv 101
5 years ago
Edited 5 years ago

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())
0
No, (unless resending the remote); but you can however use remote functions, which are exactly made for that User#20388 0 — 5y
0
Okay so how? Explain Remote Functions then, never used them.. NorteX_tv 101 — 5y
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 GoldAngelInDisguise 297 — 5y
0
Thanks, real helpful. Also, why not a answer? I could accept it and we would be both happy :P NorteX_tv 101 — 5y

Answer this question