I’m attempting to make a nuclear power plant game, and I came up with this too simple to be true script that controls everything in just 45 lines of code.
local Temperature = script.Parent.Temperature
local Pressure = script.Parent.Pressure
local rodsUpIn = script.Parent.RodsUpIn
local rodsMidIn = script.Parent.RodsMidIn
local rodsDownIn = script.Parent.RodsDownIn
print("Reactor Script loading...")
if rodsUpIn.Value == true and rodsMidIn.Value == true and rodsDownIn.Value == true then
print("1")
local increaseTemp = Temperature.Value/100
local waitTime = math.random(4, 10)
for Temperature = 0, increaseTemp do
Temperature.Value = Temperature.Value + increaseTemp
wait(waitTime)
end
local increasePressure = Pressure.Value/100
for Pressure = 0, increasePressure do
Pressure.Value = Pressure.Value + increasePressure
end
elseif rodsUpIn.Value == true and rodsMidIn.Value == true or rodsUpIn.Value == true and rodsDownIn.Value == true or rodsMidIn.Value == true and rodsMidIn.Value == true then
print("2")
local increaseTemp = Temperature.Value/150
local waitTime = math.random(4, 10)
for Temperature = 0, increaseTemp do
Temperature.Value = Temperature.Value + increaseTemp
wait(waitTime)
end
local increasePressure = Pressure.Value/150
for Pressure = 0, increasePressure do
Pressure.Value = Pressure.Value + increasePressure
end
elseif rodsUpIn.Value == true or rodsMidIn.Value == true or rodsDownIn.Value == true then
print("2")
local increaseTemp = Temperature.Value/200
local waitTime = math.random(4, 10)
for Temperature = 0, increaseTemp do
Temperature.Value = Temperature.Value + increaseTemp
wait(waitTime)
end
local increasePressure = Pressure.Value/200
for Pressure = 0, increasePressure do
Pressure.Value = Pressure.Value + increasePressure
end
end
But like I said, too simple to be true, and it can’t get past any of the if statements. Why is this?
Could be that your script doesn’t recognize the values immediately and sets them as nil, or your values were never true in the first place.
I feel as if we’re lacking a little context.
is this a local script/server script?
does your script print “Reactor Script loading…?”
does this script run the if statements over and over under a loop we don’t see?
do the values of your booleans start off true or false?
do the values of your booleans even change at all on client/serverside?
These are all questions you should answer before giving it to us with little context. Not trying to grill you, just trying to get you to ask for assistance if you’ve investigated/tried everything you can.
Server script, does print “Reactor Script loading…”
Does not run in a loop.
The only booleans that are there are Meltdown, The rods values, and Running
The booleans I haven’t tested, I am just trying to get the reactor to function.
As of right now, as soon as the script loads it runs once and then ends. Also it doesn’t wait for your values to load in. (which isn’t a good habit to get in to btw)
Chances are your boolean values(RodIn, RodOut, RodMid, etc.) are preset to false, so when it runs just the one time it completely ignores them, or the thread is moving so fast it recognizes the values as false.
To check add a wait before the conditional statements.