I'm trying to make a lobby script, and they're two teams. So if the player team = "Robbers" then it would get teleported, and if the player team = "Cops" then they get teleported, but to a different position. I tried doing this. The problem is the player doesn't teleport, and there are no errors. This is a localscript.
local target = CFrame.new(22.323, 6.1, -138.402)
for i, player in ipairs(game.Players:GetChildren()) do
if player.Team == "Robbers" and player.Character:FindFirstChild("HumanoidRootPart") then
player.Character.HumanoidRootPart.CFrame = target
print "Teleported"
----------------FULL LOBBY SCRIPT------------------
local timer = script.Parent.StatusTag
local player = game.Players.LocalPlayer
local maps = game:GetService("ServerStorage"):GetChildren()
local chosenmap = maps[math.random(1, 2)]
function begin()
for i = 5, 0, -1 do -- 5 seconds for intermission
wait(1)
timer.Text = "Intermission: "..i
if i == 0 then
timer.Text = "Choose your Team!"
chosenmap:Clone().Parent = game.Workspace --map preload
player.PlayerGui.TeamGui.Main.Visible = true
wait(5)-- 5 seconds to pick a team
timer.Text = "Game Started!"
player.PlayerGui.TeamGui.Main.Visible = false
local target = CFrame.new(22.323, 6.1, -138.402)
for i, player in ipairs(game.Players:GetChildren()) do
if player.Team == "Robbers" and player.Character:FindFirstChild("HumanoidRootPart") then
player.Character.HumanoidRootPart.CFrame = target
print "Teleported"
end
end
end
end
end
begin()
|