Hello, I'm making a terminal and it has a while loop that adds +1 to a intValue. Whenever it runs it just spams +1.
I have filtering enabled, I am using a server script.
--tIme is defined up more in the script
while tIme.Value < 10 do --runs when tIme.Value is lower than ten, low number for testing
wait(1) --Wait nevers waits
tIme.Value = tIme.Value + 1 -- adds 1 to the value
end
Any help would be appreciated.
EDIT: Whole script.
local gameRunning = game:GetService("ServerScriptService").Start.running
local beam = script.Parent.Parent.Beam
local text = game:GetService("ServerScriptService").Start.text
local timer = game:GetService("ServerScriptService").Start.timer
local tIme = script.Parent.time
script.Parent.Touched:connect(function(hit)
if gameRunning.Value == false then return end
if hit.Parent:FindFirstChild("Humanoid") then
local char = hit.Parent
local plr = game.Players:GetPlayerFromCharacter(char)
if plr.TeamColor == BrickColor.new("Really red") then
beam.BrickColor = BrickColor.new("Really red")
text.Value = "Red team owns the hill!"
--Here to
while tIme.Value < 10 do
wait(1)
tIme.Value = tIme.Value + 1
end
--Here
text.Value = "Red has won!"
elseif plr.TeamColor == BrickColor.new("Really blue") then
beam.BrickColor = BrickColor.new("Really blue")
text.Value = "Blue team owns the hill!"
--Here
while tIme.Value < 10 do
wait(1)
tIme.Value = tIme.Value + 1
end
--Here
text.Value = "Blue has won!"
end
end
end)
Between the --here are where the while loops I am having problems with are.

6 comments
I copied that and had that going on my side, it works fine for me. The problem exists outside of the script you're showing
I have a function that checks if the intValue changes and it updates a StringValue.Value to the IntValue.Value. Would this be the cause?
what output are you getting, also are you getting any errors?
I am getting no output or errors. Just adds 1 like 5 times a second without waiting.
You need to add a debounce
It works! Thank you.