Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Countdown script not counting down?

trying to make a round style game with a countdown that teleports you to and from the lobby the teleport part works but the countdown GUI only says Label.

script in server script service

local roundLength = 10
local intermissionLength = 10
local InRound = game.ReplicatedStorage.InRound
local Status = game.ReplicatedStorage.Status

local LobbySpawn = game.Workspace.LobbySpawn
local GameAreaSpawn = game.Workspace.GameAreaSpawn

InRound.Changed:Connect(function()
wait(1)
    if InRound.Value == true then
        for _, player in pairs(game.Players:GetChildren()) do
            local char = player.Character
            char.HumanoidRootPart.CFrame = GameAreaSpawn.CFrame 
        end
    else
        for _, player in pairs(game.Players:GetChildren()) do
            local char = player.Character
            char.HumanoidRootPart.CFrame = LobbySpawn.CFrame
        end
    end
end)



local function roundTimer()
    while wait() do
        for i = intermissionLength, 1, -1 do
            InRound.Value = false
            wait(1)
            Status.Value = "Intermission: ".. i .." seconds left!"
        end
        for i = roundLength, 1, -1 do
            InRound.Value = true
            wait(1)
            Status.Value = "Game: ".. i .." seconds left!"
        end
    end
end

spawn(roundTimer)

localscript in screengui

local Status = game.ReplicatedStorage.Status
local TimerDisplay = script.Parent.timerDisplay

Status.Changed:Connect(function()
    TimerDisplay.Text = Status.Value
end)

1 answer

The problem is the local script, You can try to change it to

local Status = game.ReplicatedStorage.Status
local TimerDisplay = script.Parent.timerDisplay
local RunService = game:GetService("RunService")

RunService.RenderStepped:Connect(function()
if TimerDisplay.Text ~= Status.Value then
      TimerDisplay.Text = Status.Value
end
end)

1 comment

0

the gui only says 0 now, no errors.

This discussion is preserved as it was. New answers, comments, and votes are closed.