The problem is that when "Accessed" is true, the value becomes 0 instantly, and not going down by 1 per second.
local Terminals = workspace.Terminals local Terminal = Terminals.Terminal local Val = Terminal.TerminalValue local Accessed = Terminal.Accessed while wait() do Accessed.Changed:connect(function(Value) if Accessed.Value == true and Val.Value > 0 then while Accessed.Value == true and Val.Value > 0 do repeat Val.Value = Val.Value - 1 wait(1) until Val.Value == 0 if Val.Value == 0 then Accessed.Value = false end end end end) end
When you are putting the Accessed.Changed function inside the while wait() do loop, it will make a new function for every loop. When the Accessed is changed, it will play all of those cloned functions at once, immediately bringing it down to zero.
You don't actually need to have a loop. You can leave the function as is!
local Terminals = workspace.Terminals local Terminal = Terminals.Terminal local Val = Terminal.TerminalValue local Accessed = Terminal.Accessed Accessed.Changed:connect(function(Value) if Accessed.Value == true and Val.Value > 0 then while Accessed.Value == true and Val.Value > 0 do repeat Val.Value = Val.Value - 1 wait(1) until Val.Value == 0 if Val.Value == 0 then Accessed.Value = false end end end end)