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

Why won't this custom spawn script work?

Asked by 9 years ago
game.Players.PlayerAdded:connect(function(plr)

    plr.Character.Humanoid.Died:connect(function(died)
        if plr.TeamColor == BrickColor.new("New Yeller") then


        wait(6)
        died.Parent:MoveTo(game.Workspace.Custom1.Position)
        elseif plr.TeamColor == BrickColor.new("Toothpaste") then
            wait(6)
            died.Parent:MoveTo(game.Workspace.SpecialSpawn2.Position)
        elseif plr.TeamColor == BrickColor.new("Pink") then
            wait(6)
            died.Parent:MoveTo(game.Workspace.Custom3.Position)
        else
            print("The player that died isn't on any of the custom spawn teams, so they weren't teleported")

        end
    end)
end)

I have made this because I already used the 4 spawns ROBLOX gave us, which means if I duplicate it, and change its color, it won't teleport you to the spawn once you die. The problem with this script is that it won't teleport at all! The only part that works is the else part. Help?

0
Whats Custom1, Custom2, Custom3? Are they bricks? Operation_Meme 890 — 9y
0
They are SpawnLocations. groovydino 2 — 9y
2
The died connect has no parameters. EzraNehemiah_TF2 3552 — 9y

1 answer

Log in to vote
1
Answered by 9 years ago
game.Players.PlayerAdded:connect(function(plr)

    local function spawnchar(position) --function to spawn player
        local spawned
        repeat wait()
        if workspace:findFirstChild(plr.Name) and workspace[plr.Name]:findFirstChild("Humanoid") then
            if workspace[plr.Name].Humanoid.Health > 0 then
                spawned = true
            end
        end
        until spawned
        plr.Character:MoveTo(position)
    end

    plr.Character.Humanoid.Died:connect(function(died)
        if plr.TeamColor == BrickColor.new("New Yeller") then
        spawn(workspace.Custom1.Position)
        elseif plr.TeamColor == BrickColor.new("Toothpaste") then
        spawn(workspace.Custom2.Position)
        elseif plr.TeamColor == BrickColor.new("Pink") then
        spawn(workspace.Custom3.Position)
        else
            print("The player that died isn't on any of the custom spawn teams, so they weren't teleported")

        end
    end)
end)

try that, this will wait until the character spawns and teleport the character to the position.

0
Are you sure this works? Did you test it? groovydino 2 — 9y
0
I didn't test it, but it should work. FutureWebsiteOwner 270 — 9y
Ad

Answer this question