Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Game Timer Text Not Changing despite making functions for It (?)

Asked by 1 year ago

Hello Developers!

As the title says, I made this round system, the problem Is that the GUI text Isn't changing

local GameTimer = 180 ---How long the round should be
local IntermissionTimer = 25 --- How long Intermission should be
local StartUpTimer = 3 ---How long will the player get ready before the round starts
local GUIMadeHint = game:GetService("StarterGui").TimerAndMessages
local HintText = GUIMadeHint.Hint.HintText
local Maps = { ---All maps---
    game:GetService("ReplicatedStorage").Maps["Old SFOTH Map"]
}

local function GameProgress()
    StartUpTimer = 3
    HintText.Text = "ROUND STARTING IN "..StartUpTimer
    --[[
        local GetReadyText = Instance.new("Hint")
    GetReadyText.Parent = game:GetService("StarterGui").HintsAndMesages
    GetReadyText.Text = "ROUND STARTING IN "..StartUpTimer
    ]]
    while StartUpTimer > 0 do
        wait(1)
        StartUpTimer -= 1
        HintText.Text = "ROUND STARTING IN "..StartUpTimer
    end
    GameTimer = 180
    HintText.Text = GameTimer.." Before round ends"
    --GetReadyText.Text = GameTimer.." Before round ends"
    while GameTimer > 0 do
        wait(1)
        GameTimer -= 1
        HintText.Text = GameTimer.." Before round ends"
    end
    --game:GetService("Debris"):AddItem(GetReadyText,0)
end

local function GameEnded()
    HintText.Text = "GAME OVER!"
    --[[
    local GameOverText = Instance.new("Hint")
    game:GetService("Debris"):AddItem(GameOverText,3)
    GameOverText.Parent = game:GetService("StarterGui").HintsAndMesages
    GameOverText.Text = "GAME OVER!"
    ]]
    wait(5)
    local MapFolder = game.Workspace.CurrentMap:GetChildren()
    for _, Map in ipairs(MapFolder) do
        if Map:IsA("Model") then
            Map:Destroy()
        end
    end
end

local function Intermission()
    IntermissionTimer = 25
    HintText.Text = "Next round starting In "..IntermissionTimer
    --[[
    local IntermissionText = Instance.new("Hint")
    IntermissionText.Parent = game:GetService("StarterGui").HintsAndMesages
    IntermissionText.Text = "Next round starting In "..IntermissionTimer
    ]]
    while IntermissionTimer > 0 do
        wait(1)
        IntermissionTimer -=1
        HintText.Text = "Next round starting In "..IntermissionTimer
    end
    --game:GetService("Debris"):AddItem(IntermissionText,0)
end

local function GameStarting()
    local SelectedMap = Maps[math.random(1,#Maps)]
    SelectedMap.Parent = game.Workspace.CurrentMap
    HintText.Text = "MAP CHOSEN: "..SelectedMap.Name
    --[[
    local MapChoosenText = Instance.new("Message")
    MapChoosenText.Parent = game:GetService("StarterGui").HintsAndMesages
    MapChoosenText.Text = "MAP CHOOSEN: "..SelectedMap.Name
    ]]
    wait(3)
    --game:GetService("Debris"):AddItem(MapChoosenText,0)
end

while true do
    GameEnded()
    Intermission()
    GameStarting()
    GameProgress()
end

1 answer

Log in to vote
1
Answered by 1 year ago
Edited 1 year ago

You need to get the GUI objects from the player's PlayerGui.

When the player joins the game, all of the contents inside of the StarterGui service will be copied over to the player's PlayerGui.

Ad

Answer this question