------------------------- -- 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.
------------------------- -- 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