Player isn't getting teleported

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.

Try Character:PivotTo(game.Workspace.SpawnLocation.CFrame + Vector3.new(0,5,0)) instead.

1 Like

It’s still the same issue in my part.

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.

1 Like

Let again, it’s still the same issue

Hello. Try doing:

Character:PivotTo(CFrame.new(game.Workspace.SpawnLocation.Position + Vector3.new(0,5,0)))

Just tested it myself and it worked flawlessly. Hope it helped!

1 Like

Is D being printed when it finds a player to teleport?

1 Like
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)
1 Like

Edited script again, try this. This should work

1 Like

Unfortunately it didn’t work. It prints but I dont get teleported.

Where did you put your Stats, leaderstats, and Stage objects under? StarterGui or…?

where did you put the script and tell me if its local or not because i might be able to work on it