Teleportation of player

Hello, I am currently trying to teleport a player to a certain position, but i want to not teleport the player immediately, So something like CFrame usage? I am new to teleporting.

The code:

game.Workspace.Gravity = 0
wait(2)
game.Players.LocalPlayer.Character:MoveTo("-51, 30, 2139")
wait(2)
game.Players.LocalPlayer.Character:MoveTo("-51, 30, 1369")
wait(2)
game.Players.LocalPlayer.Character:MoveTo("-51, 30, 2909")
wait(2)
game.Players.LocalPlayer.Character:MoveTo("-51, 30, 3679")
wait(2)
game.Players.LocalPlayer.Character:MoveTo("-51, 30, 4449")
wait(2)
game.Players.LocalPlayer.Character:MoveTo("-51, 30, 5219")
wait(2)
game.Players.LocalPlayer.Character:MoveTo("-51, 30, 6759")
wait(2)
game.Players.LocalPlayer.Character:MoveTo("-51, 30, 5989")
wait(2)
game.Players.LocalPlayer.Character:MoveTo("-51, 30, 7529")
wait(2)
game.Players.LocalPlayer.Character:MoveTo("-51, 30, 8299")
wait(2)
2 Likes

You should use TweenService for this.

3 Likes

If I understood you correctly, you want to teleport the character
To do that you directly type in Character.HumanoidRootPart.Position = Vector.new(x, y, z) instead of using MoveTo. Also MoveTo will not work in this case since its a method of Humanoid, and you call it on the character model.
Edit: Oh yeah I misread that a bit, if you want the character to smoothly transition between one place and another you should tween or lerp the HumanoidRootPart of it. Since I personally hate tweens I will provide an example with lerping. You also should use a set of positions to lerp between

local RunService = game:GetService("RunService")

local alpha = 0
local transitionSpeed = 0.1
		
local HumanoidRootPart = Character.HumanoidRootPart
	HumanoidRootPart.Anchored = true
		
local Connection
Connection = RunService.Stepped:Connect(function(Time, DeltaTime)
	alpha += DeltaTime * transitionSpeed
	HumanoidRootPart.Position = HumanoidRootPart.Position:Lerp(Vector3.new(100, 100, 100), alpha)
	if alpha >= 1 then
		HumanoidRootPart.Anchored = false
		Connection:Disconnect()
	end
end)
1 Like

Try this? (nvm someone already responded)

local TweenService = game:GetService("TweenService")
local HRP = game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart")

game.Workspace.Gravity = 0
wait(2)
TweenService:Create(HRP, TweenInfo.new(2), {CFrame = CFrame.new(Vector3.new(-51, 30, 2909))}):Play()
wait(2)
TweenService:Create(HRP, TweenInfo.new(2), {CFrame = CFrame.new(Vector3.new(-51, 30, 3679))}):Play()
wait(2)
TweenService:Create(HRP, TweenInfo.new(2), {CFrame = CFrame.new(Vector3.new(-51, 30, 4449))}):Play()
wait(2)
TweenService:Create(HRP, TweenInfo.new(2), {CFrame = CFrame.new(Vector3.new(-51, 30, 5219))}):Play()
wait(2)
TweenService:Create(HRP, TweenInfo.new(2), {CFrame = CFrame.new(Vector3.new(-51, 30, 6759))}):Play()
wait(2)
TweenService:Create(HRP, TweenInfo.new(2), {CFrame = CFrame.new(Vector3.new(-51, 30, 5989))}):Play()
wait(2)
TweenService:Create(HRP, TweenInfo.new(2), {CFrame = CFrame.new(Vector3.new(-51, 30, 7529))}):Play()
wait(2)
TweenService:Create(HRP, TweenInfo.new(2), {CFrame = CFrame.new(Vector3.new(-51, 30, 8299))}):Play()
wait(2)
2 Likes

Oh my! Thanks so much!

But i found another thing, when I want to use MoveTo function, which i need to, It is teleporting me above the part, because the teleport position is in a part. Can you help me?

1 Like

Try changing the part’s CanCollide to false and Anchored to true

It is a part waiting to be touched (.Touched) so it is anchored and no collisions already. Should I use CFrame?

Yea try out CFrames to check if it works

I don’t know how, I’ll try some wiki.

1 Like

How are you even using MoveTo? Are you like trolling and Character is an abstract class with :MoveTo(Position: string) method?

Sorry, I am new to teleporting, as I stated… I just don’t know how to use CFrame, so I tried using game.Players.LocalPlayer.Character:MoveTo
I am not trolling.

1 Like

Sorry, but there are just a lot of things wrong with that
you cant call MoveTo with a model, its a method of a humanoid
then you are passing a string to it, and it only accepts Vector3 datatype

Well it works, I think it does the teleport above the part because the teleport is inside a part, But I found a way to do it through CFrame.

I don’t want to make a new comment, but I want to thank all that helped me :slight_smile:

1 Like