I'll give you a full example to help spell RemoteFunctions out for you. :)
First of all, always, always, always, store Scripts in the ServerScriptService when you are able to, as in this case. Your probability of having your game exploited drops significantly when you follow this rule.
Here is the code for this example:
02 | local func = Instance.new( "RemoteFunction" , Game:GetService( "ReplicatedStorage" )) |
07 | func.OnServerInvoke = function (player) |
08 | for _, v in ipairs (cops) do |
09 | if v = = player.Name then return true end |
2 | local func = Game:GetService( "ReplicatedStorage" ):WaitForChild( "isACop" ) |
4 | local isCop = func:InvokeServer() |
The LocalScript will Invoke the RemoteFunction for every Player, every time they respawn. The OnServerInvoke callback function in the Script receives this Invoke for each player
, and returns the boolean true
or false
depending on whether or not the client-that-the-invoke-originated-from's Player is a cop or not. This return is carried back to the LocalScript, setting the isCop value there.