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

How to fix this error - attempt to compare number with boolean with NumberValue?

Code -

local Player = game.Players.LocalPlayer

local ConfirmButton = script.Parent:WaitForChild("ConfirmButton")
local CancelButton = script.Parent:WaitForChild("CancelButton")
local TitleText = script.Parent:WaitForChild("Title")
local EnterGroupID = script.Parent:WaitForChild("GroupID")
local GangName = script.Parent:WaitForChild("GangName")
local GroupID = script.Parent:WaitForChild("GroupIDVal")
local GangNameVal = script.Parent:WaitForChild("GangNameVal")
local GroupIDVariable = tonumber(GroupID.Value)

GangName:GetPropertyChangedSignal("Text"):Connect(function(text)
    GangNameVariable = GangNameVal.Value
end)

EnterGroupID:GetPropertyChangedSignal("Text"):Connect(function(text)
    GroupIDVariable = tonumber(GroupID.Value)

end)

ConfirmButton.MouseButton1Click:Connect(function()
    if Player.InGang.Value == true then
        TitleText.Text = "YOU ARE ALREADY IN A GANG"
        wait(2)
        TitleText.Text = "MUST OWN A ROBLOX GROUP TO MAKE A GANG"
    elseif GangNameVariable == nil then
        TitleText.Text = "MUST ENTER AN APPROPRIATE GANG NAME"
        wait(2)
        TitleText.Text = "MUST OWN A ROBLOX GROUP TO MAKE A GANG"
    elseif GroupIDVariable == nil then
        TitleText.Text = "MUST ENTER AN APPROPRIATE GROUP ID"
        wait(2)
        TitleText.Text = "MUST OWN A ROBLOX GROUP TO MAKE A GANG"
   elseif Player:GetRankInGroup(tonumber(GroupID.Value)) ~= nil and not Player:GetRankInGroup(tonumber(GroupID.Value)) >= 255 then
        TitleText.Text = "YOU MUST OWN THE ROBLOX GROUP"
        wait(2)
        TitleText.Text = "MUST OWN A ROBLOX GROUP TO MAKE A GANG"
    elseif Player.InGang.Value == false then
        print("Works")
    end
end)

**Error - **

 03:31:58.809 - Players.USAGroup_Holder.PlayerGui.GangCreation.Gang.FrameHandler:34: attempt to compare number with boolean
03:31:58.810 - Stack Begin
03:31:58.810 - Script 'Players.USAGroup_Holder.PlayerGui.GangCreation.Gang.FrameHandler', Line 34
03:31:58.811 - Stack End

1 answer

✓ Accepted answer

Line 34

You are trying to see if their rank in the group is nil. You cannot compare a boolean to a number value.

Try replacing it with this

elseif Player:GetRankInGroup(tonumber(GroupID.Value)) < 255 then

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