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

First when player have touched the finishline it resets?

Asked by
iNicklas 215 Moderation Voter
8 years ago
while wait(.1) do
    p = game.Players:GetChildren()
    if #p > 1 then
        script.Parent.Text = "A new race will begin in"
        wait(1)
        script.Parent.Text = "3"
        wait(1)
        script.Parent.Text = "2"
        wait(1)
        script.Parent.Text = "1"
        wait(1)
        script.Parent.Text = "Go!"

        ----------HERE

    elseif #p <= 1 then
        script.Parent.Text = "1 more player is needed"
    end
end

1 answer

Log in to vote
0
Answered by 8 years ago

You can see if someone touched the finish line using a touched script:

while wait(.1) do
    p = game.Players:GetPlayers() --I'm going to use GetPlayers instead of GetChildren.
    if #p > 1 then
        script.Parent.Text = "A new race will begin in"
        wait(1)
        script.Parent.Text = "3"
        wait(1)
        script.Parent.Text = "2"
        wait(1)
        script.Parent.Text = "1"
        wait(1)
        script.Parent.Text = "Go!"

    workspace.FinishLine.Touched:connect(function(p)
        if p.Parent:FindFirstChild("Humanoid") then
            local char = script.Parent
            local plyr = game:GetService("Players"):GetPlayerFromCharacter(char)
            --I got the player and character, you can finish the rest.
        end
    end

    elseif #p <= 1 then
        script.Parent.Text = "1 more player is needed"
    end
end

Hope it helps!

Ad

Answer this question