Why is my script calling a nil value even though I have defined a value?

So this is a script that, disables the anti-exploit script for anyone in a specific Group with a Group Rank, but I am having an error which is saying:

attempt to call a nil value, Line 22

Here is the script:

------------------------------------------------------------CONFIGURATION-------------------------------------------------------------------------
local Group_ID = 3514227

local Group_Rank = 255

--------------------------------------------------------------------------------------------------------------------------------------------------



local Players = game:GetService("Players")

local LocalPlayer = game.Players.LocalPlayer

local Player = game.Players:GetPlayers()

local RealAnti = script.Parent:WaitForChild("RealAnti")


while wait() do
	if script.Parent:FindFirstChild("RealAnti") == nil and not Player:GetRankInGroup(Group_ID) >= Group_Rank then
		LocalPlayer:Kick("Nope")
	elseif RealAnti.Disabled == true and not Player:GetRankInGroup(Group_ID) >= Group_Rank then
		RealAnti.Disabled = false	
	end
end

Correct me if i’m wrong, but aren’t you checking Players:GetPlayers(), which is referenced as Player, on the two group rank conditions on the while loop instead of LocalPlayer?

1 Like

Ah yes, you are right, however am having another issue with attempting to index nil with WaitForChild, I would try to get help with it in another topic, thanks.