Why does this Chance script NOT work?

local rDROP = math.random(1, 100) -- Chance
	
if rDROP >= 1 and not rDROP >= 79 then
	-- common
elseif rDROP >= 80 and not rDROP >= 99 then
	-- rare
elseif rDROP >= 100 and not rDROP <= 99 then
	-- epic
end

This is a theoretical chance script I want to use, and the reason it doesn’t work is because the “not rDROP <= x” is underlined orange, why is that? How do I make this work?

Any help is appreciated!

lua sees the and not rDROP <= x expression as and not rDROP
to fix this you have to surround it in parentheses

local rDROP = math.random(1, 100) -- Chance
	
if rDROP >= 1 and not (rDROP >= 79) then
	-- common
elseif rDROP >= 80 and not (rDROP >= 99) then
	-- rare
elseif rDROP >= 100 and not (rDROP <= 99) then
	-- epic
end
4 Likes

I see, thank you! It works now, I would’ve never though of that!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.