Why does script teleport me to a random location

So when im equipping a startercharacter the script just randomly teleports me to a new location, why?

local CharacterClone = game.ReplicatedStorage:FindFirstChild("Imposter"):Clone()
		print("Cloned")
		CharacterClone.Name = player.Name
		print(CharacterClone.Name)
		player.Character:Destroy()
		print("Destroyed")
		player.Character = CharacterClone
		print("Nearly")
		CharacterClone.Parent = game.Workspace

Because your startercharacter as a another position.

You can fix this with setting the CFrame of the new character to the CFrame of the old character

local CharacterClone = game.ReplicatedStorage:FindFirstChild("Imposter"):Clone()
   	print("Cloned")
   	CharacterClone.Name = player.Name
   	print(CharacterClone.Name)
    local cframe= player.Character.HumanoidRootPart.CFrame


   	player.Character:Destroy()
   	print("Destroyed")
   	player.Character = CharacterClone
   	print("Nearly")
    local root = CharacterClone:WaitForChild("HumanoidRootPart")
    local hum = CharacterClone:WaitForChild("Humanoid")
    wait()
    root.CFrame = cframe

   	CharacterClone.Parent = game.Workspace

Thanks it works

1 Like