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

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

Asked by 8 years ago
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?

1
It really make it difficult for us to help you when people like yourself don't put their codes inside the Code Block. UserOnly20Characters 890 — 8y
0
fixed! hurricanedog 0 — 8y
0
Oh, I was going to post an answer with it code blocked... I removed it! General_Scripter 425 — 8y
0
You didnt make gui a variable. TrollD3 105 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

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
Ad

Answer this question