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

How can I teleport certain players to certain spawns?

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

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

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

spawns = mapChosenClone.Spawns:GetChildren()
for i,v in pairs(game.Players:GetChildren()) do
    name = v.Name
    check = game.Workspace:FindFirstChild(name)
        if check then
            checkHumanoid = check:FindFirstChild("Humanoid")
            if checkHumanoid then
                check:MoveTo(spawns[i].Position)
        end
    end
end

Ok so what I have the script do is pick 1 random player to be a killer and the rest are runners. I need the Teleport part of the script to teleport the runners to a certain brick and the killer to another brick, like deathrun. Could I insert a BoolValue or stringvalue, that when the Killer is chosen they get a boolvalue and then tps the killer to a certain block within the map. Anyone know what I am doing wrong?

1 answer

Log in to vote
0
Answered by
Moryo7 15
10 years ago

You don't really need to waste space with that, just set the value using the script. Try this:

-------------------------
-- Picks random killer --
-------------------------

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

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

spawns = mapChosenClone.Spawns:GetChildren()
for i,v in pairs(game.Players:GetChildren()) do
    name = v.Name
    check = game.Workspace:FindFirstChild(name)
        if check then
            checkHumanoid = check:FindFirstChild("Humanoid")
            if checkHumanoid and name ~= killer then -- name is the name of the player, yes?
                check:MoveTo(spawns[i].Position)
            elseif checkHumanoid and name == killer then
        check:MoveTo() -- Dont forget to put in the coordinates. I dont know where the spawn is.
        end
    end
end

0
That works, but its like deathrun. I need it so when the killer is chosen it asks if player is killer then change teamcolor to red. Then I need if teamcolor = red then MoveTo(RedSpawn) thats what I need, not coordenates NinjoOnline 1146 — 10y
0
Also line 25 "name" == v.Name NinjoOnline 1146 — 10y
Ad

Answer this question