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

Count down for round timer is working but troubleshooting in output??

Asked by 6 years ago
Edited 6 years ago
local txt = {"Time left until next round: "}

function startPr()
    for j = 300, 0, -1 do
        for i,v in pairs(game.Players:GetChildren()) do
            v.PlayerGui.ScreenGui.Frame.TextLabel.Text = txt[1]..j
        end
        wait(1)
    end
end

startPr()

20:32:25.161 - ScreenGui is not a valid member of Player

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

EDIT: Just realised I made an error and did "WaitForChild" instead of FindFirstChild

I had the same problem earlier today. I'm assuming you're using R15, in R6, this would show no errors. My way to fix it was to wait for it to load so:

local txt = {"Time left until next round: "}

function startPr()
    for j = 300, 0, -1 do
        for i,v in pairs(game.Players:GetChildren()) do
            if v:FindFirstChild("PlayerGui") then
                if v.PlayerGui:FindFirstChild("ScreenGui") then
                    v.PlayerGui.ScreenGui.Frame.TextLabel.Text = txt[1]..j
                end
            end
        end
        wait(1)
    end
end

startPr()
Ad

Answer this question