I need an almost equal system for an if statement [REPOST]

for my core game, i need an almost equal system that checks if a IntValue’s number is between 14950 and 15050 and if its between said numbers, run a script

i dont know how to make this, so please help?

You can simply check if it is between the two values using two conditions in an if statement.

if number > 14950 and number < 15050 then
     -- code here
end
1 Like
if number > 14950 and number < 15050 then
      -- code here and replace "number" with your number
end

When I posted my code yours popped up for me, I don’t know if it’s a bug but I did not copy your code.

im testing right now

char limit

heres my code from @Jzwhale

i edited it to fit my needs, and it didnt work


no output is sent to the output

You are comparing the IntValue to the number, not the IntValue’s value. Try the following where it instead compares the IntValue’s “Value” property.

while true do
     local value = workspace.Values.TemperatureSystem.Temperature.Value
     if value > 12950 and value < 13050 then
          print("reached over 12950")
     end

     task.wait()
end

i just realized i compared it to the intvalue object and not the intvalue’s value

1 Like

forgot to mention (sorry)

it fires a bunch of times when inbetween, and i only want it to fire once

might be able to fix this myself

You can exit out of a while loop using a “break” statement.

while true do
     local value = workspace.Values.TemperatureSystem.Temperature.Value
     if value > 12950 and value < 13050 then
          print("reached over 12950")
          break
     end

     task.wait()
end

This will wait until the temperature is between the two values and then exit out of the while loop.

i plan on adding more stuff for higher temperatures, so i cant break the loop

i used a boolvalue to check if its false, and if it is, run code, set it to true, which prevents it from restarting

1 Like