Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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.

3 comments

0

what?

0

i want to kick the player if they have neither of them

1

Yeah just read my answer. I literally explained it all.

This discussion is preserved as it was. New answers, comments, and votes are closed.