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

Why won't my script work?

function timeri(timei)
	local timerValuei = timei
while timerValuei ~= 0 do
	wait(1)
	timerValuei = timerValuei - 1
	for i, v in pairs(game.Players:GetChildren()) do
		v.Name.PlayerGui.ScreenGui.TextLabel.Text = "Intermission: " .. timerValuei
	end
end

end

It gives me an error that PlayerGui is trying to be indexed (nil value)

1 answer

✓ Accepted answer

On line 7 you have to remove the .Name after the v which represents the players it's checking. You have to do this because the PlayersGui is not a member of the name property. So the code should be,

function timeri(timei)
    local timerValuei = timei
while timerValuei ~= 0 do
    wait(1)
    timerValuei = timerValuei - 1
    for i, v in pairs(game.Players:GetChildren()) do
        v.PlayerGui.ScreenGui.TextLabel.Text = "Intermission: " .. timerValuei--Remove .Name
    end
end

end

Hope that helped! Good Luck!

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