I can't teleport Person

Hello.
I was doing my game and I need when player join to teleport him to seat so he sit’s down,
This is my code:

game.Players.PlayerAdded:Connect(function(plr)
	print("Hmm")
	repeat
		wait()
	until plr.CharacterAdded:Wait() and plr.Character.Humanoid and plr.Character.HumanoidRootPart
	print("nice")
	plr.Character.HumanoidRootPart.CFrame = game.Workspace.Seat.CFrame
	plr.Character.HumanoidRootPart.Anchored = true
	local Clone = game.ReplicatedStorage.Flashlight:Clone()
	Clone.Parent = plr.Backpack
	plr.Character.Humanoid:EquipTool(Clone)
end)

But I will spawn at void ?!

So I don’t know why this is happening

Thank for any help!

2 Likes

Try doing

game.Workspace.Seat:Sit(plr.Character.Humanoid)

instead of

plr.Character.HumanoidRootPart.CFrame = game.Workspace.Seat.CFrame
3 Likes

Try this

game.Players.PlayerAdded:Connect(function(plr)
	print("Hmm")
plr.CharacterAdded:Connect(function(char)
	print("nice")
	char.HumanoidRootPart.CFrame = game.Workspace.Seat.CFrame -- idk if your seat is a part or a actual seat
	char.HumanoidRootPart.Anchored = true 
	local Clone = game.ReplicatedStorage.Flashlight:Clone()
	Clone.Parent = plr.Backpack
	char.Humanoid:EquipTool(Clone)
end)
end)
2 Likes

The players won’t get teleported when they first join the game, they will only teleport when they oof and respawn again.

1 Like

Is suggest using

InstanceSeat:Sit(TheHumanoidOfThatPlayer)

Just now saw what the guy above me said

2 Likes

Nope this is not working.

Try removing this line:

plr.Character.HumanoidRootPart.Anchored = true
2 Likes

CharacterAdded doesnt fire when the player dies it fires when player’s character pops up which is when the game starts

1 Like

I tried it and it makes no sense.

1 Like

CharacterAdded doesn’t work when the player spawns for the first time in the game, at least for me.

1 Like

This is not working either but thank for trying me help.

1 Like

I suggested that because maybe the humanoidrootpart was getting anchored before the player sitting on that seat.

1 Like

I already said that do no sense. Because it is not working.

1 Like

CharacterAdded fires so early the character first gets teleported to that location, and then actually gets teleported to the spawn, therefore making it seem like the teleport never happened.

The only way to fix this is to wait for a few moments before attempting teleportation, or wait until the character is no longer at 0,0,0. It’s a hacky and bad solution, but it’s the only possible way to do this as far as I’m aware.

1 Like

Sorry but this is not working either

1 Like

In my experience, CharacterAdded doesn’t necessarily mean that the character is parented to workspace - you should include something to check that it is before calling :MoveTo, :SetPrimaryPartCFrame, or whatever else you’re using.

game:GetService("Players").PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		local CharacterInWorkspace
		CharacterInWorkspace = Character.Changed:Connect(function()
			if Character.Parent == workspace then
				print("Character added into workspace - you can now call :MoveTo or :SetPrimaryPartCFrame.")
				CharacterInWorkspace:Disconnect()
			end
		end)
	end)
end)

image

1 Like

Instead of using a repeat until loop, it’s better to do…

local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
...

Also, your repeat until loop will yield at until plr.CharacterAdded:Wait() and plr.Character.Humanoid and plr.Character.HumanoidRootPart since, :Wait() will cause your current thread to yield until the event .CharacterAdded has fired, so, it’s pretty useless either way.

You have used it incorrectly, search devforum about it i also had that issue.