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

Why isn't this teleport script working?

Asked by 10 years ago
-------------------------
-- Picks random killer --
-------------------------

        players = game.Players:GetChildren()
        local randomp = players[math.random(1,#players)]
        print(randomp.Name .. " is killer")
        randomp.TeamColor = BrickColor.new("Bright red")
        for i,v in pairs(players)  do
            if v.Name ~= randomp.Name then
                print(v.Name .. " is runner")
                v.TeamColor = BrickColor.new("Bright blue")
            end
        end

---------------------------------
-- Teleport players to the map --
---------------------------------

        rspawn = mapChosenClone.RunnerSpawn:GetChildren()
        kspawn = mapChosenClone.KillerSpawn:GetChildren()

        for i,v in pairs(game.Players:GetChildren()) do
            name = v.Name
            check = game.Workspace:FindFirstChild(name)
            if game.Players.TeamColor == "Bright red" then
                check:MoveTo(kspawn[i].Position)
            elseif game.Players.TeamColor == "Bright blue" then
                check:MoveTo(rspawn[i].Position)
            end
        end

How can I get this to teleport killers to kspawn and runners to rspawn. It works so it picks a killer and the rest are runners. I need it see if a player is on red team, then move them to a spawn or if their on blue move them to a dif spawn. Only on the teleport part is what needs help.

1 answer

Log in to vote
-1
Answered by
Nickoakz 231 Moderation Voter
10 years ago
-------------------------
-- Picks random killer --
-------------------------
    players = game.Players:GetChildren()
    local randomp = players[math.random(1,#players)]
    print(randomp.Name .. " is killer")
    randomp.TeamColor = BrickColor.new("Bright red")
    for i,v in pairs(players)  do
        if v.Name ~= randomp.Name then
            print(v.Name .. " is runner")
            v.TeamColor = BrickColor.new("Bright blue")
        end
    end
---------------------------------
-- Teleport players to the map --
---------------------------------
    rspawn = mapChosenClone.RunnerSpawn:GetChildren()
    kspawn = mapChosenClone.KillerSpawn:GetChildren()

    for i,v in pairs(game.Players:GetChildren()) do
        pcall(function() --To prevent breaking if the Character.Torso is nil
            if v.TeamColor == "Bright red" then
                v.Character.Torso.CFrame=(
                    CFrame.new(kspawn[i].Position+Vector3.new(0,3,0))
                )
            elseif v.TeamColor == "Bright blue" then
                v.Character.Torso.CFrame=(
                    CFrame.new(rspawn[i].Position+Vector3.new(0,3,0))
                )
            end
        end)
    end
0
can I get it so instead of a location, it mvoes to a thing NinjoOnline 1146 — 10y
0
that broke the game NinjoOnline 1146 — 10y
Ad

Answer this question