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

Timer won't work and gets an error when i remove the first 3 lines.. Any help..?

Asked by 6 years ago

Hai, I am greatneil80 and I made a timer In starter Gui and once it becomes 0, players get teleported to a map... Unfortunately it won't work in the real game mode... I wanted to know how to fix up my script from doing that...

repeat
    wait()
until game:GetService("Players").LocalPlayer



local oldMessage = "Hai, game currently beta mode"
local minPlayers = 1
function teleportAllPlayers()
    local target = CFrame.new(workspace.TeleportArena["Future Escape Teleport"].Position)
    for i, player in ipairs(game.Players:GetChildren()) do
        player.Character.UpperTorso.CFrame = target + Vector3.new(0, i * 5, 0)
        player.Playing.Value = 1
        --add an offset of 5 for each character
    end
end

function message(message)
    if oldMessage ~= message then
        oldMessage = message
        print(message)
    end
end

function playersCurrentlyPlaying()
    for i, player in ipairs(game.Players:GetChildren()) do
        if player.Playing.Value == 1 then return true end
    end
    return false
end

game:GetService('Players').PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        character:WaitForChild("Humanoid").Died:connect(function()
            player.Playing.Value = 0
        end)
    end)

    local playing = Instance.new("IntValue", player)
    playing.Value = 0
    playing.Name = "Playing"
end)


while(true) do
    wait(5)
    local timer = 40
    local Text = game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui"):FindFirstChild("Timer").TextLabel
    repeat

        timer = timer - 1
        Text.Text = "Intermission of "..timer.." Seconds"
        wait(1)
    until timer < 1

        Text.Text = "Teleporting Players..."
    if #game.Players:getPlayers() >= minPlayers then
        if playersCurrentlyPlaying() then
            message("Waiting for the current game to end...")
        else
            message("There are enough players for a new game!  Teleporting...")
            wait(4)
            teleportAllPlayers()
            timer = 150
            repeat
                timer = timer - 1
                Text.Text = "Round going on for "..timer.." Seconds"
                wait(1)
            until timer < 1
            if game.Players.LocalPlayer then
            if game.Players.LocalPlayer.Playing.Value == 1 then
                local hewmannoid = game:GetService("Players").LocalPlayer.Character.Humanoid
                hewmannoid.Health = 0
            else
                game:GetService("Players"):WaitForChild(game.Players.LocalPlayer.Name)
            end
            end
        end
    else message("Waiting for more players...") end
end

By what I know, the first 3 lines wait for the Players and later on it can get the players name but, It won't work in the real mode... Any Help..?

0
It is a requirement that the local player must have loaded, because PlayerGui is a parent of the player, unless this script is in ReplicatedFirst or something. hiimgoodpack 2009 — 6y
0
Which is why in the start I wait for the "Players" section to get loaded greatneil80 2647 — 6y

Answer this question