So I'm fairly new to it all, so can anyonen help me?
local funct = game:GetService("ReplicatedStorage"):FindFirstChild("Functions") local player = game.Players.LocalPlayer function isaCop.OnServerInvoke(player,currentCops) end
isaCop is the Child of the RemoteFunction named Functions.
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:
--Script in ServerScriptService local func = Instance.new("RemoteFunction", Game:GetService("ReplicatedStorage")) func.Name = "isACop" local cops = {} --I assume this is full of Player names. func.OnServerInvoke = function(player) for _, v in ipairs(cops) do if v == player.Name then return true end end return false end
--LocalScript in PlayerGui 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.