So I get the basic concept of remote functions and events, and I read several questions that were answered on here and read the wiki.
but I still can't figure out how to activate a specified function via the remote.
((Plus I honestly don't know where to put the scripts and the remote function/remote event))
So how would I go after defining say a "touched" function to telling the server to do a certain function like adding to a player's Item value?
((My verbal instructions so far))
local script
blocked touched begin function (hit)
if hit.parent == Humanoid then
invoke server function (Add)
end)
Server function
1.If message == 'Add' then
2.Player.Value = Player.Value + 5
3.end
I have no idea where to put the scripts and the remotefunction object. Plus I'm not sure how to make the remotefunction object invoke the Add function.
Any assistance would be really nice and helpful!
((PS. I'm sorry I didn't write a script, but I have no idea where to place everything so I can give you a actual error..))
All RemoteEvents (RE) and RemoteFunctions (RF) go into ReplicatedStorage, so that both client and server have easy access. Remember, both objects are just slightly different version of BindableEvent and BindableFunction which have existed for a long time. All you are doing is sending information.
You use a BindableFunction if you need a return value from the other side, therefore it yields. Otherwise you use a RemoteEvent. You usually use the latter.
You can look at the wiki for the actual syntax. Most importantly remember you are not sending info to anywhere specific; you are sending info into a void, and can happen to listen to it. Therefore you check every argument from the RE. Also remember that they are not totally secure. Exploiters can know all arguments you send, and even FireServer at will. Therefore you should do rigorous checks on all info the client sends. Lastly, I recommend sending all info through tuples in which the first argument is the script you intend to receive it. It's very organized.
It might sound hard or restrictive at first but you will find that they result in exactly the opposite. Plus, with FE, there's nothing better than having a secure game.