Teleporting character doesnt work

I am trying to teleport the character when they click a button. Honestly I have no idea what is going on because this has never happened to me.

I am not getting anything in the output either so I dont know what is going on.

None of these work:

char:MoveTo(game.Workspace.CapturePoint.Position)
char.HumanoidRootPart.CFrame = game.Workspace.CapturePoint.Position

This is how I get the character: (This shouldnt be the problem)

local char = plr.Character or plr.CharacterAdded:Wait()
1 Like

There may be a problem with the plr variable. Can I see how you got that?

1 Like

game.Players.LocalPlayer

wait, I just realised. I am doing it from a local script. Dumb me. But however, the code has worked in the past, so I dont know what is the problem

1 Like
char.HumanoidRootPart.CFrame = game.Workspace.CapturePoint.Position

This line doesn’t work because you can’t set a CFrame to a position. You can set a CFrame to a CFrame or a Position to a Position

1 Like
--local script
local part = workspace:FindFirstChild("Part")
local plr = game:GetService("Players").LocalPlayer
local chr = plr.Character or plr.CharacterAdded:Wait()

task.wait(5)
plr.Character:MoveTo(part.CFrame.p + Vector3.new(0, 3.5, 0))
1 Like

chuck this part of your code inside CFrame.new() and it should work

oh nah, I set the CFrame to the Part’s CFrame, I just made a mistake in the devforum post, mb

Did you even check my script. Works perfectly. Part being where you’re moving to.

I just tried your one, it works sometimes. But it doesnt always work

It’s a program it works the same 100% of the time.

If you’re using a time faster than 5 seconds You may need to wait for humanoid
local humanoid = chr:WaitForChild(“Humanoid”)

If you’re not dong this right off the login you wouldn’t even need to wait and only need the plr part.

These are just stalling for the player to load fully.
local chr = plr.Character or plr.CharacterAdded:Wait()
local humanoid = chr:WaitForChild(“Humanoid”)

I just realised. My character variable was at the top of the script and the script doesnt reset when the character dies. My bad

To fix this, I just put the character variable inside of the function

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