whats the main difference from remote functions and remote events? when is approppiate to use either?
Say you wanted to get a value of the client while using FE, you would make a script like:
01 | -- Server Script |
02 | rf = Instance.new( "RemoteFunction" , workspace) |
03 | rf.Name = "GetPlayerName" |
04 | -- Client Script |
05 | rf = workspace:WaitForChild( "GetPlayerName" ) |
06 | rf.OnClientInvoke = function () -- Callback function |
07 | return game.Players.LocalPlayer.Name |
08 | end |
09 | -- Other Server Script |
10 | print (workspace.GetPlayerName:InvokeClient(game.Players.SebbyTheGODKid)) |
That will print "SebbyTheGODKid"
But say you JUST wanted to use a remote event to place a block from the client:
01 | -- Server Script |
02 | re = Instance.new( "RemoteEvent" , workspace) |
03 | re.Name = "PlaceBlock" |
04 | re.OnServerEvent:Connect( function (pos) |
05 | if pos ~ = nil then |
06 | part = Instance.new( "Part" , workspace) |
07 | part.Position = pos |
08 | end |
09 | end ) |
10 | -- Client Script |
11 | workspace.PlaceBlock:FireServer() -- Returns nothing, but places a block on the server even with FE. |
Hope that helps!
Straight from roblox forum.
"The first difference is that RemoteFunctions are designed for two way communication, while RemoteEvents are designed for one way. A RemoteFunction sends a request and then waits for a response, while RemoteEvents just send a request."
For a better description, you can go on the forum itself.
Link: http://wiki.roblox.com/index.php?title=Remote_Events_and_Functions
I dont really know the difference myself, so I just used the wiki, lmao.