Hey, so i want to Debugg my Countdown script im working on…
im having issue with the Text that gets diplayed it works one time but after that if i press my button again the Countdown displays and quickly changes again to the countdown and again and again, again… you get it right?
so its very important that if i click the button again the Countdown works normally and if the button is not clicked and the Countdown is over the script should wait until the button is clicked and repeats.
local roundLength = 30
local intermissionLength = 0
local inRound = game.ReplicatedStorage.inRound
local Status = game.ReplicatedStorage.Status
local function roundCountdown()
while wait() do
for i = roundLength, 1, -1 do
inRound.Value = false
wait(1)
Status.Value = "Game: "..i.." seconds left!"
print(Status.Value)
end
for i = intermissionLength, 0, -0 do
inRound.Value = false
wait(1)
Status.Value = "intermission: Press the Button to Start the Game!"
end
end
end
local onCooldown = false
wait(game.Workspace.General.Button.ClickDetector.MouseClick:Connect(function(click)
if onCooldown == false then
onCooldown = true
spawn(roundCountdown)
task.delay(30, function()
onCooldown = false
end)
end
end))
so if you could fix the little thing im having issues with i would learn something from it and i can work on other parts of my game.
local roundLength = 30
local intermissionLength = 0
local inRound = game.ReplicatedStorage:WaitForChild("inRound")
local Status = game.ReplicatedStorage:WaitForChild("Status")
local onCooldown = false
local function roundCountdown()
for i = roundLength, 1, -1 do
inRound.Value = false
task.wait(1)
Status.Value = "Game: "..i.." seconds left!"
print(Status.Value)
end
for i = intermissionLength, 0, -0 do
inRound.Value = false
task.wait(1)
Status.Value = "intermission: Press the Button to Start the Game!"
end
end
game.Workspace.General.Button.ClickDetector.MouseClick:Connect(function(click)
if onCooldown == false then
onCooldown = true
spawn(roundCountdown)
task.delay(30, function()
onCooldown = false
end)
end
end)
local Status = game.ReplicatedStorage.Status
local CountdownDisplay = script.Parent.CountdownDisplay
Status.Changed:Connect(function()
CountdownDisplay.Text = Status.Value
end)
local roundLength = 30
local intermissionLength = 0
local inRound = game.ReplicatedStorage:WaitForChild("inRound")
local Status = game.ReplicatedStorage:WaitForChild("Status")
local Test = false
local onCooldown = false
local function Intermission()
inRound.Value = false
Status.Value = "intermission: Press the Button to Start the Game!"
end
local function roundCountdown()
for i = roundLength, 0, -1 do
inRound.Value = false
task.wait(1)
Status.Value = "Game: "..i.." seconds left!"
if i < 1 then
print(Status.Value)
Intermission()
end
end
end
game.Workspace.General.Button.ClickDetector.MouseClick:Connect(function(click)
if onCooldown == false then
onCooldown = true
spawn(roundCountdown)
task.delay(30, function()
onCooldown = false
end)
end
end)