I am trying to make this lose 10s off the countdown once a player touches a part, my solutions so far have lead the countdown/values to go into negatives then straight away pick back up where it left off. For example it would go to something like -90 then right back to where it was which is no good .
Other than this small issue, the countdown works fine until I try to complete this ^
Has anybody got any ideas on how I’d do this?
local function Countdown()
print("COUNTDOWN")
while wait() do
for i = gameplayTime, 1, -1 do
gameStarted.Value = true
wait(1)
countdownV.Value = i
gameStatus.Value = "In game"
end
end
end
local function Countdown()
print("COUNTDOWN")
for i = 1, gameplayTime, -1 do
task.wait(1)
countdownV.Value = gameplayTime - i
end
gameStarted.Value = true
gameStatus.Value = "In game"
end
local function Countdown()
print("COUNTDOWN")
gameStarted.Value = true
gameStatus.Value = "In game"
for i = 0, gameplayTime do
countdownV.Value = gameplayTime - i
task.wait(1)
end
end
yes, 10 seconds off the remaining time, if there was for example, 100 seconds left on the countdown, someone touches the part, it goes down by an additional 10 and continues - repeating for every time someone touches said part. thanks for your help
local function Countdown()
countdownV.Value = gameplayTime
local Connection
Connection = Part.Touched:Connect(function()
countdownV.Value += -10
end)
while countdownV.Value >= 0 do
countdownV.Value += -1
task.wait(1)
end
Connection:Disconnect()
end
local function GameplayCountdown()
countdownV.Value = gameplayTime
gameStatus.Value = "In game"
local Connection
Connection = maps.ObbyLevels:FindFirstChildWhichIsA("Model").FinishedPart.Touched:Connect(function()
print("touched countdown")
print("countdownAdjust")
countdownV.Value = countdownV.Value - 10
end
end)
while countdownV.Value >= 0 do
countdownV.Value += -1
task.wait(1)
end
Connection:Disconnect()
end
gave it a go, nothing prints and nothing happens, got any more ideas? I know the player is touching the part because other parts of the script are working fine when the player touches the part.
local function GameplayCountdown()
countdownV.Value = gameplayTime
gameStatus.Value = "In game"
local Connection
Connection = maps.ObbyLevels:FindFirstChildWhichIsA("Model").FinishedPart.Touched:Connect(function()
print("touched countdown")
print("countdownAdjust")
countdownV.Value = countdownV.Value - 10
end
end)
while countdownV.Value >= 0 do
countdownV.Value += -1
task.wait(1)
end
Connection:Disconnect()
end
I just thought I would mention this, make sure you add a debounce or it will be spammed.
Or if you only want it to decrease by ten seconds once, make sure you disconnect the event after it has fired.