Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

This reactor core coolant script doesn't work as intended, any help?

Asked by 4 years ago
Edited 4 years ago

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
0
I'm not that experienced of a scripter, let me know of any of my mistakes. Branden14545 0 — 4y
0
first of all why is there no "wait" in your infinite loop that can causes the game to freeze up LoganboyInCO 150 — 4y
0
second of all i suggest using number values for temperatures then have the text set its text as the number value LoganboyInCO 150 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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.

0
Didn't work, sadly. It still automatically puts the temp down to 0. Branden14545 0 — 4y
0
Oh i forgot between 5 and 6 you need to put wait(1) or any number of second you want to wait until it changes the num value dinozaver_triceratop 78 — 4y
0
The problem is, if I put the text to any other number (say 159), it will automatically put it to 100 and start going down. Branden14545 0 — 4y
0
You need to change num to any number (say 159), but if your reactor becomes hotter because of any other script you will need to make an int value. Then do num = (path to the int value) and all other scripts that change temperature will need to change this int value. Hope this helps dinozaver_triceratop 78 — 4y
Ad

Answer this question