#How to make it work better
1 messages · Page 1 of 1 (latest)
local player = game.Players.LocalPlayer
local textlabel = player.PlayerGui.Thermodynamics.TDFrame.Frame1.AVGTemperature
local avgtemperature = game.ReplicatedStorage.AverageTemp
while true do
task.wait(1)
textlabel.AVGTemperatureValue.Text = avgtemperature.Value
if avgtemperature.Value == 30 or 31 or 32 or 33 or 34 or 35 then
textlabel.AVGTemperatureValue.TextColor = Vector3.new(235, 0, 0)
elseif avgtemperature.Value == 20 or 21 or 22 or 23 or 24 or 25 or 26 or 27 or 28 or 29 then
textlabel.AVGTemperatureValue.TextColor = Vector3.new(155, 62, 9)
end
end
You can use the < and > symbols to detect if the number is within a certain range. for example you can replace the first if statement that checks if the temperature if above 30, and do
if avgtemperature.Value >= 30 then
--change color to red
end
in this case >= is checking if the number is equal to or greater than 30
Yes but if I do >= 20 then it goes from 2O to infinity, I want it to go from 20 to 29
in this case you can just do >= 20 as an elseif statement to the if >= 30 if statement, this will automatically check the range between 20 to 29 because the first if statement is already checking if its a larger number than 30, and if its false, then it will check the elseif
hold up let me explain better
The first if statement
if num >= 30 then
Checks for any number above 30
If we add an elseif that is connected to the if statement, that condition will only be checked if the number is under 30
why not just do
if (num >= 30 and num <= 35) then
you could, the original post just said if the temp is bigger than 30, so i went off of that
okay thanks!
you can do this for the second if thatment instead if my explanation was too much
just change the numbers to be between 20 to 29
The point behind what we were saying is that if statements can have many conditions. but you can't quite compare it by doing or, because, even though english dictates that "if temperature is 30, or 31, or 32" might make sense, to a computer that's saying "if temperature is 30, or if the number 31 is true, or if the number 32 is true"
oh okay thank you!
do that