Can anyone tell me where it is going wrong? The error is on line 28.
GroupID = 4057855 Door = script.Parent Kill = false Teleport = false X = 0 Y = 0 Z = 0 DB = false script.Parent.Touched:connect(function(p) if p.Parent:FindFirstChild("Humanoid") then local player = game.Players:GetPlayerFromCharacter(p.Parent) if player then if not DB then DB = true if player:GetRankInGroup(GroupID) >=3 then if not Teleport then Door.Transparency = 0.4 Door.CanCollide = false wait(0.3) Door.Transparency = 0 Door.CanCollide = true DB = false elseif Teleport then player.Character.Torso.CFrame = CFrame.new(X,Y+2,Z) DB = false end elseif not player:GetRankInGroup(GroupID) >=3 then if Kill then p.Parent.Humanoid.Health = 0 DB = false elseif not Kill then DB = false end end end end end end)
The problem is that the not
operator in Lua has higher precedence than equality operators.
So when you do:
elseif not player:GetRankInGroup(GroupID) >= 3 then
You are essentially doing this:
elseif (not player:GetRankInGroup(GroupID)) >= 3 then
Because player:GetRankInGroup()
always returns an integer from 0 to 255, and only false
and nil
are falsey values in Lua, the not
operator in your case yields us false
.