MoveTo() not working

Hey,
I’m trying to teleport the player whenever it dies to the last checkpoint.
Howhere, the following line of the script doesn’t work:

Player.Character:MoveTo(Check.CFrame.Position)

Here’s a part of the script to give an idea:

--Service
local Players = game:GetService("Players")
local DSS = game:GetService("DataStoreService")
local CDS = DSS:GetDataStore("ChartDataStore")

--On player joins
function New(Player)
	
	local function Character(Char)
		--MovePlayer
		local Folder = game.Workspace.Data:WaitForChild(Player.Name)
		local Check = game.Workspace.Checkpoints:WaitForChild(Folder.Value)
		print(Check)
		Player.Character:MoveTo(Check.CFrame.Position)
	end
	
	Player.CharacterAdded:Connect(Character)
	
end

--On player Left
function Left(Player)
	--Stuff
end

--Starter
Players.PlayerAdded:Connect(New)
Players.PlayerRemoving:Connect(Left)

Thank you all a lot!

Try this instead:

--Service
local Players = game:GetService("Players")
local DSS = game:GetService("DataStoreService")
local CDS = DSS:GetDataStore("ChartDataStore")

--On player joins
function New(Player)
	
	local function Character(Char)
		--MovePlayer
task.wait()
		local Folder = game.Workspace.Data:WaitForChild(Player.Name)
		local Check = game.Workspace.Checkpoints:WaitForChild(Folder.Value)
		print(Check)
		Player.Character:MoveTo(Check.CFrame.Position)
	end
	
	Player.CharacterAdded:Connect(Character)
	
end

--On player Left
function Left(Player)
	--Stuff
end

--Starter
Players.PlayerAdded:Connect(New)
Players.PlayerRemoving:Connect(Left)
1 Like

Try this because you are trying to MoveTo the character even tho it supposed to be the Humanoid that u use the MoveTo Function.

Script:

function New(Player)
Player.CharacterAdded:Connect(Character)
end

function Character(Char)
local Humanoid = Char:WaitForChild(“Humanoid”)
local Folder = game.Workspace.Data:WaitForChild(Char.Name)

local Check = game.Workspace.Checkpoints:WaitForChild(Folder.Value)

Char.Humanoid:MoveTo(Check.CFrame.Position)

end

Players.PlayerAdded:Connect(New)

1 Like

Thank you both.
@BIULDERBRO @lilmazen1234

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.