I want to function as: If a coolant is on, the temp goes down until it reaches the temp of 0. Instead, for example, if the text = 200, it puts it to 0 upon running the script. Any help?
if workspace.TVCOOL.Part.SurfaceGui.STATUS.Text == 'ON' then while true do workspace.TVTEMP.Part.SurfaceGui.Temp.Text = workspace.TVTEMP.Part.SurfaceGui.Temp.Text - 1 if workspace.TVTEMP.Part.SurfaceGui.Temp.Text == '0' then break end end end
I think it is because Temp.Text is a string but you want to do math on it like it is a number. I think you should do something like this:
local num = 100 -- change to any number if workspace.TVCOOL.Part.SurfaceGui.STATUS.Text == 'ON' then while true do num = num - 1 workspace.TVTEMP.Part.SurfaceGui.Temp.Text = num wait(1) if num == 0 then break end end end
Hope this helps.