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

How do I break this while loop, and run a seperate line of code for when coretemp equals 8999?

Asked by 7 years ago

So the problem is, if I implement the Meltdown Code I know it's going to constantly run infinitely, and I don't want that. So how can I make it only run once, while I have a while loop present?

01coretemp = script.Parent.coretemp
02heatmult = script.Parent.heatmult
03coolmult = script.Parent.coolmult
04 
05coretemp.Value = 2000 -- Starting Core Temperature
06heatmult.Value = 1 -- Starting heat multiplier
07coolmult.Value = 0 -- Starting cool multiplier
08 
09corestatus = "SAFE"
10 
11function heatgeneration()
12    wait(1)
13    if heatmult.Value > coolmult.Value then
14        coretemp.Value = coretemp.Value + 1 * heatmult.Value
15    elseif coolmult.Value > heatmult.Value then
View all 44 lines...
0
This script is the code of a Nuclear Reactor I am building. Inevitable_Judgement -10 — 7y

1 answer

Log in to vote
0
Answered by
hellmatic 1523 Moderation Voter
7 years ago
1while wait() do
2    if coretemp.Value < 9000 then
3        status()
4 
5    elseif coretemp.Value > 8999 then
6        coretemp.Value = 9000
7        break
8    end
9end
0
don't know what you mean by 'seperate line of code' hellmatic 1523 — 7y
0
Basically, I was going to have a seperate function for the meltdown code without creating a new script. But thank you you've fixed my problem. I wasn't sure if this was gonna work. Inevitable_Judgement -10 — 7y
0
I'm gonna have to restructure the whole script I'm afraid. But now I know how to do it. :) Inevitable_Judgement -10 — 7y
Ad

Answer this question