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

Is there a problem with this script? What else do I have to do, to make a GUI for this appear?

local minutes = 5 -- What the timer starts from
local seconds = 00  -- What the timer starts from
local min = minutes
local sec = seconds

function killPlayers()
    local a = game.Players:GetChildren()
    for _,v in pairs (a) do
        v.Character:BreakJoints() -- Kills the player
    end
end

while true do
    wait(1)
    sec = sec - 1
    if sec == 0 then
        min = min - 1
        if min == 0 then
            killPlayers()
            min = minutes
            sec = seconds
        else
            sec = 59
        end
    end
    local count = min.. ":" ..sec
    Gui.Text = count
end

I previously received help with this script, to act as a countdown for when all humanoids die. Do I need to make a GUI for this, with another script? Can someone help me figure out my problem?

4 comments

1

It really make it difficult for us to help you when people like yourself don't put their codes inside the Code Block.

0

fixed!

0

Oh, I was going to post an answer with it code blocked... I removed it!

0

You didnt make gui a variable.

1 answer

I previously answered, but I guess I didn't explain it properly:

You need to create a Gui, just put in StarterGui. Then you make a variable for it, E.G:

local gui = player.PlayerGui.ScreenGui -- player is undefined as of yet (this is an example)

We need to make it so that it does it on every player's screen, so:

while true do
	wait(1)
	sec = sec - 1
	if sec == 0 then
		min = min - 1
		if min == 0 then
			KillPlayers()
			min = minutes -- reset the timer
			sec = seconds
		else
			sec = 59
		end
	end
	local count = min.. ":" ..sec.. " until players die."
	local a = game.Players:GetChildren()
	for _,v in pairs(a) do -- loop that gets all of the players and changes the text
		local gui = v.PlayerGui:FindFirstChild("ScreenGui")
		if gui then
			gui.TextLabel.Text = count
		end
	end
end

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