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 'attempt to compare boolean and number'?

My script is;

local int = game.Players.LocalPlayer.leaderstats:WaitForChild("level")
local textlabel = script.Parent
game.Players.LocalPlayer.leaderstats.level.Changed:Connect(function(change)
if int.Value >= tonumber(0) <= tonumber(4) then
	textlabel.Text = "Novice"
	if int.Value >= tonumber(5) <= tonumber(9) then
		textlabel.Text = "Intermediate"
		if int.Value >= 10 <= 14 then
			textlabel.Text = "Advanced"
			if int.Value >= 15 <= 24 then
				textlabel.Text = "Skilled"
				if int.Value >= 25 then
					textlabel.Text = "Expert"
				end
				end
		end
	end
	end
game.Players.LocalPlayer.leaderstats.level.Changed:Connect()
    change()
end)

1 answer

✓ Accepted answer

You can't do compound comparisons in Lua, instead you have to use or & and statements.

if int.Value >= 0 and int.Value <= 4 then... if int.Value >= 5 and int.Value <= 9 then...

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