✓ Accepted answer
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:
local func = Instance.new("RemoteFunction", Game:GetService("ReplicatedStorage"))
func.Name = "isACop"
local cops = {}
func.OnServerInvoke = function(player)
for _, v in ipairs(cops) do
if v == player.Name then return true end
end
return false
end
local func = Game:GetService("ReplicatedStorage"):WaitForChild("isACop")
local isCop = func:InvokeServer()
print(isCop)
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.
2 comments
so what is the _, v for?
https://scriptinghelpers.org/questions/5619/what-is-_letter-and-whats-the-difference-between-pair-and-pairs '_' is a valid character for use in variable names in Lua. When used alone, like in that generic for loop, it implies that the value it holds is not going to be used.