How can I see the exact change in a number

Hello, So I have a random int and I want to check if that value increased by exactly 1 from what it was before. Ex:

while wait() do 
local Int;
Int = math.random(1, 22)
local NewValue = Int
if  NewValue  = NewValue + 1 then -- Idk i forgor lua :skull: , but im tryna check if the value increased by only 1
-- Do what ever
   end
end 

I’m sure the solution is simple by im kinda braindead rn, :pray:

EDIT: I Figured it out my brain just shut down for a bit. (It’s working again)

2 Likes

You can do something like this:

local int = math.random(1, 22)
local old = int

-- do changes to int (not old)

if int == old + 1 then
	warn("yes it is")
else
	warn("noooooo")
end
2 Likes

I tried that and it didn’t work, but I ended up finding the solution.

1 Like

Why do you need to see the exact change in the first place? What are you using it for?

1 Like

I’m just testing end points in my game

2 Likes

In that case, you should probably click Solution on your comment since it’s already solved.

2 Likes