Hey, so I’m trying to make the client ask the server if the user is REDACTED, however I’m passing the player as an argument in a RemoteFunction, sadly, in the script, the argument is nil. Why?
Script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remotes = ReplicatedStorage.Remotes
local Remote = Remotes.lbi
local ServerScriptService = game:GetService("ServerScriptService")
local Modules = ServerScriptService.Modules
local Utils = require(Modules:WaitForChild("Utils"))
local redactmodule = require(Modules:WaitForChild("RedactModule"))
local function giveRedact(plr, arg)
print(arg)
local Data = Utils.GetData(arg)
if not Data then return plr:Kick(Utils.Error("No data.")) end
local isredvalue = Data.isRedacted.Value
if isredvalue == true then
return true
else
return false
end
end
Remote.OnServerInvoke = giveRedact```
LocalScript:
for i,v in pairs(Players:GetChildren()) do
local redactinfo = game:GetService("ReplicatedStorage").Remotes.lbi:InvokeServer(v)
local ServerScriptService = game:GetService("ServerScriptService")
local PlayerData = ServerScriptService:WaitForChild("PlayerData")
local Utils = {}
Utils.Error = function(...)
local Args = {...}
local ErrorMessage = table.concat(Args)
return "Error: " .. ErrorMessage .. "!"
end
Utils.GetData = function(Player)
if not PlayerData:FindFirstChild(Player.UserId) then return nil end
return PlayerData:FindFirstChild(Player.UserId)
end
return Utils
Even if arg wasn’t nil, it looks like for the given client, it will attempt to check Data for every player in the game. And if any player has no data, then the calling client will get kicked. This may or may not be the player that actually has no data. I’m guessing that’s not the desired behavior. I could also be reading the code wrong. It just seems like you should be invoking the remote function only for the current client’s LocalPlayer instead of using that for-loop.