Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

3 comments

0

I'm not that experienced of a scripter, let me know of any of my mistakes.

0

first of all why is there no "wait" in your infinite loop that can causes the game to freeze up

0

second of all i suggest using number values for temperatures then have the text set its text as the number value

1 answer

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.

4 comments

0

Didn't work, sadly. It still automatically puts the temp down to 0.

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

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.

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

This discussion is preserved as it was. New answers, comments, and votes are closed.