Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

why wont this let me be in game if i got one thing or the other?

Asked by 5 years ago

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

1 answer

Log in to vote
1
Answered by 5 years ago

De Morgan's Laws

Boolean logic is whack

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.

0
what? Gameplayer365247v2 1055 — 5y
0
i want to kick the player if they have neither of them Gameplayer365247v2 1055 — 5y
1
Yeah just read my answer. I literally explained it all. User#6546 35 — 5y
Ad

Answer this question