The Player teleports to the wrong CFrame

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to know why my character wont teleport to the specified cframe.

  2. What is the issue? Include screenshots / videos if possible!
    I have a line of code to change the player rootpart cframe to a part cframe, in studio it works, but outside of studio, they teleport to a whole new location.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried using position, but the same happens. Ive tried searching for an fix, but I couldn’t find any good ones.

I also dont get any errors, which makes it a ton harder to figure out what is happening.

The script changing the cframe is this:

local character = plr.Character
local part = Workspace.Map.Spawn
character.HumanoidRootPart.CFrame = part.CFrame

Any help is appreciated! :grinning:

1 Like

Its probably because the teleportation part isn’t anchored.

Some parts may not be loaded as soon as game begins so you need to use :WaitForChild() instead of .
Try this code:
(or the problem may be the part isn’t anchored as @slatinedd says)

local character = plr.Character or plr:CharacterAdded:Wait()
local HumanoidRootPart = character:WaitForChild("HumanoidRootPart")
local part = Workspace:WaitForChild("Map"):WaitForChild("Spawn")
HumanoidRootPart.CFrame = part.CFrame
1 Like

yeah, that makes sense seeming as if its a on-join teleportation type thing. However, why not just use a spawn-block for that type of stuff? It’s much simpler and easier

Is this done in a local script?

The part is anchored. And the position doesn’t change

No, in an modulescript being required by an server script

Its not onjoin, it happens later in the game

I’ll try using it and I will tell you if it works

Ok i tried it and the same happens, but im also confused why it only works in studio but not in servers/outside of studio.

Okay, i found a solution. I just had to anchor the rootpart and when teleported, i unanchor it.