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

"Attempted to compare a number with boolean" ??

Asked by 6 years ago

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)
0
The (not) checks the value for true/false only. You would do if player:GetRankInGroup(GroupID) < 3 then... TiredMelon 405 — 6y

1 answer

Log in to vote
0
Answered by
Avigant 2374 Moderation Voter Community Moderator
6 years ago

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.

Ad

Answer this question