|
| 07 Nov 2015 03:07 PM |
| How do I use them and what do they do? I didn't properly understand the wiki. |
|
|
| Report Abuse |
|
|
| |
|
|
| 07 Nov 2015 03:19 PM |
Remotefunctions are used to communicate between the server and the client.
Remotefunctions have 2 main yieldfunctions and 2 main callbacks
Yieldfunctions: InvokeClient will call a given players client with certain arguments to the function. InvokeServer will call the server from the local client.
Callbacks: You can see the callbacks sort of like events. As soon as you invoke the client or server the function on the other side will trigger and do it's job, you can also return values if you so wish.
The example that the roblox wiki gives is the following:
Codebit on the server (Script): -- function RemoteFunction.OnServerInvoke(player, name) print("Hi, my name is", name, "and this invocation came from", player.Name) return player.Name end --
Output: Hi, my name is John Doe and this invocation came from Player1
Codebit on the server (Script): -- print(RemoteFunction:InvokeServer("John Doe")) --
Output: Player1
Let's break this code down. The server script defines a function called Remotefunction and there is a serverinvoke assigned to it with takes 2 arguments: Player and name. If the function is called it will print out the given sentence and it will return the name of the player who called the function.
On the client side you see someone call this: print(RemoteFunction:InvokeServer("John Doe"))
You might be thinking "What, I thought u said the function took 2 ARGUMENTS!". This is right, however when invoking the server from a client you do not need to supply the first player argument, roblox assigns this argument for you automatically. In this case you just have to supply the second argument Name. What the code itself does it basically prints out the returned value from the script that is located on the serverside by using the invokeserver command.
I hope this cleared up at least something for you. I am not that great at explaining things very detailed.
.Net, C#, C++, Java and much more. |
|
|
| Report Abuse |
|
|
|
| 07 Nov 2015 03:20 PM |
Just typed this entire nonsense to see that you already figured it out as soon as I was done. Well played.
.Net, C#, C++, Java and much more. |
|
|
| Report Abuse |
|
|
| |
|
|
| 07 Nov 2015 03:28 PM |
FloweryMonkeyboy5,
You helped me as I was also stuck on this, so thank you! :)
~~Head of Moderation and Application at F3X~~ |
|
|
| Report Abuse |
|
|