Yes, I know this is very similar to another post but that didn’t really help
while task.wait(0.1) do
if game.ServerStorage.ReactorStats.Tempature == game.ServerStorage.ReactorStats.MeltdownTemp then
local click = Instance.new("ClickDetector")
click.Parent = script.Parent
local chance = nil
click.MouseClick:Connect(function()
local chance = math.random(1,2)
if chance == 1 then
game.ReplicatedStorage.remotes.SCRAMStatus:FireAllClients("success")
repeat
game.ServerStorage.CoolantRods.CoolantRods.Value += 14.2857142857
until
task.wait(7)
else
game.ReplicatedStorage.remotes.SCRAMStatus:FireAllClients("failed")
end
end)
end
end
anyone know why the error happens and how I can fix it?
Having more events doesn’t make it update faster. In fact, you might be slowing down your connections by doing this. Just connect once to your .MouseClick event.
It’s going to add a new click detector every 0.1 seconds that pass. What you need to do instead is check and see if the new value in .Changed just passed the meltdown threshold. I’ve written it up, now you just need to fill in the rest of it.
local currTempValue: NumberValue = game.ServerStorage.ReactorStats.Temperature
local meltdownTemp: number = game.ServerStorage.ReactorStats.MeltdownTemp.Value
local isMeltingDown: boolean = false
currTempValue.Changed:Connect(function(newValue: number)
if newValue >= meltdownTemp and not isMeltingDown then
-- Just began melting down
isMeltingDown = true
-- you fill in the rest of the code here
elseif newValue < meltdownTemp and isMeltingDown then
-- Just stopped melting down
isMeltingDown = false
-- here, you revert all of the changed added by the meltdown
end
end)