i want my anti cheat script to kick you if u run too fast without having something in their backpack or if they dont have a gamepass, i used jailbreaks gamepass for testing since i bought it here is the server script
local firstpos while wait() do for i,v in pairs(game.Workspace:GetChildren()) do if v:FindFirstChild("HumanoidRootPart") then if v.Humanoid.Sit == false then firstpos = v.HumanoidRootPart.Position local player = game.Players:GetPlayerFromCharacter(v) wait(1) if (firstpos - v.HumanoidRootPart.Position).magnitude > 32 then if not player.Backpack:FindFirstChild("admin") or not game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,2218187) then print((firstpos - v.HumanoidRootPart.Position).magnitude) print("no") player:Kick("u cant cheat stupid") end end end end end end
if i delete the backpack check then it works just fine but i want it to check in the backpack since those 2 options are the exceptions to being allowed to run fast
Looking at your script, your if statement will kick the player if they don't have both the backpack element, and the gamepass. You want to kick them if they have neither.
In essence, you want logic that looks like not (hasBackpack or hasGamepass)
, however you have not hasBackpack or not hasGamepass
. Applying some lovely Boolean Algebra laws we can find that your current condition is equivalent to not (hasBackpack and hasGamepass)
.
The solution? Just fix the boolean condition. Either switch your or
for an and
, or simplify the not
.