I am working on an anticheat for roblox that will make it so almost every hack will not be possible to preform in a game. However, the module script for it keeps returning attempting to index nil with FindFirstChild in the output. How would I go about fixing this? Here is the module. the error is on line 29. It should not be returning nil, as I have checked the path of the object and it is there. The path is game.Players.LocalPlayer.PlayerGui.ValidGui.ScreenGui. (Screen Gui being v.) I am getting the local player from a server script using the game.Players.PlayerAdded:Connect(function(plr). I then send the playerGui to the module using the Distributekeys() function. Server script is after the module script.
local module = {}
ValidKeys = {}
GUiNumber = {}
-- game.Players.PlayerAdded:Connect(function(plr) don't mind this function, I am not using it.
-- player = plr
-- end)
ValidGui1 = game.StarterGui.ValidGui
function module.Store(key, UiNumber)
table.insert(ValidKeys, key)
table.insert(GUiNumber, UiNumber)
end
function module.GetFullPath(Ui)
partPath = Ui:GetFullName()
local appendStr = "game."
end
function module.GiveGuiKey(Ui)
local key = Instance.new("StringValue")
local hasgivenkey = nil
module.GetFullPath(Ui)
key.Parent = Ui
key.Name = "key"
key.Value = math.random(154122412, 521532125)
hasgivenkey = true
module.Store(key.Value, partPath)
end
function module.CheckForExploits()
for i,v in pairs(ValidKeys) do
local guinumber = GUiNumber[v]
local iskey = guinumber:FindFirstChild("key")
if iskey then
local key = GUiNumber[v]:FindFirstChild("key")
if key.Value ~= v then
script.RemoteEvent:FireServer(plr)
end
else
script.RemoteEvent:FireServer(plr)
end
end
end
function module.DistributeKeys(get)
for i, v in pairs(get:GetChildren()) do
if v:IsA("ScreenGui") and not v:FindFirstChild("key") then
module.GiveGuiKey(v)
end
end
print(GUiNumber)
end
return module
server script looks something like this.
module = require(game:GetService("ReplicatedStorage").Module)
game.Players.PlayerAdded:Connect(function(plr)
module.DistributeKeys(plr.PlayerGui)
while wait() do
module.CheckForExploits()
game:GetService("ReplicatedStorage").module.RemoteEvent.OnServerEvent:Connect(
function(plr) -- continuation of line 6.
plr:Kick("We have detected a use of exploits. Roblox does not support exploits.")
end)
end
end)

4 comments
To continue the cutoff of line 6, the part that is cut off is plr).
Perhaps try using WaitForChild?
I have already tried that
The object I am calling is there, as I have checked. It is returning nil for some reason when the object I'm trying to find is there.