I'm trying to make something of a core game, like pine wood builders computer core. I'm still in the basic stages but I want to make it so that way when I press the on button the coolant turns on and slows the process, when the off button is pressed the coolant turns off. I already set this up, but when I try to use buttons it is not working. It works if I just changes cia to true and false manually, but not with the buttons. You can visit the game if you want. Here is my code:
local core = workspace.Core
local basetemp = 500
local temp = game.Workspace.temp.Value
local c = true
local cia = false
if cia == true then
c = false
end
while c == true do
temp = temp + math.random(1,3)
print(temp)
script.Parent.SurfaceGui.ctemp.Text = "CORE TEMP:".. temp
wait(2)
end
while cia == true do
temp = temp + math.random(1,2)
wait(1)
temp = temp - math.random(1,2)
wait(3)
script.Parent.SurfaceGui.ctemp.Text = "CORE TEMP:".. temp
script.Parent.Parent.Coolant.SurfaceGui.cool.Text = "COOLANT IS ON"
print(temp)
end
function coolon(playerWhoClicked)
cia = true
end
function cooloff(playerWhoClicked)
cia = false
end
game.Workspace.Core.con.ClickDetector.MouseClick:connect(coolon)
game.Workspace.Core.coff.ClickDetector.MouseClick:connect(cooloff)
