local Players = game:GetService("Players")
function FindPlayer(Character)
if Character and game.Players:GetPlayerFromCharacter(Character) then
return true
else
return false
end
end
function Teleport(Stage, Character)
local HRP = Character.PrimaryPart
if Stage.Value == "Start" and FindPlayer(Character) then
HRP.CFrame = game.Workspace.SpawnLocation.CFrame + Vector3.new(0,5,0)
print("D")
elseif Stage.Value == "Bunker" and FindPlayer(Character) then
HRP.CFrame = game.Workspace["Checkpoint 1"].Spawn.CFrame + Vector3.new(0,5,0)
print("D")
end
end
Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local Folder = Player:FindFirstChild("Stats")
if not Folder then
Folder = Player:FindFirstChild("leaderstats")
end
local Stage = Folder:FindFirstChild("Stage")
Teleport(Stage, Character)
end)
end)
I don’t really know. I get the prints but it doesn’t teleport me. It may be the slowness of the game.
Hmm. Probably not going to work, and this will sound a little stupid, but try using the HumanoidRootPart instead of the PrimaryPart. I can almost 100% guarantee the PrimaryPart is the HumanoidRootPart, especially if you aren’t using custom characters, but it may not be.
local Players = game:GetService("Players")
function FindPlayer(Character)
if Character and game.Players:GetPlayerFromCharacter(Character) then
return true
else
return false
end
end
function Teleport(Stage, Character)
local HRP = Character:WaitForChild("HumanoidRootPart")
if Stage.Value == "Start" and FindPlayer(Character) then
HRP:PivotTo(game.Workspace.SpawnLocation.CFrame*CFrame.new(Vector3.new(0,5,0)))
print("D")
elseif Stage.Value == "Bunker" and FindPlayer(Character) then
HRP:PivotTo(game.Workspace:WaitForChild('Checkpoint 1').CFrame*CFrame.new(Vector3.new(0,5,0)))
print("D")
end
end
local function newCharacter(Player,Character)
local Stage = Player:WaitForChild("Stats"):WaitForChild("Stage")
Teleport(Stage, Character)
end
Players.PlayerAdded:Connect(function(Player)
newCharacter(Player,(Player.Character or Player.CharacterAdded:Wait()))
Player.CharacterAdded:Connect(function(Character)
newCharacter(Player,Character)
end)
end)