I've recently been working a lot with CFrame mechanics while scripting and I've got kind of stuck on this.
Even after using .lookVector, or even Vector3, the Jetpack model position stays equal to the position of the Torso instead of 5 (* -5) behind the torso.
Here is the code I have so far:
local player = script.Parent local jetpack = game.ReplicatedStorage.Jetpack local jetpackClone = jetpack:Clone() jetpackClone.PrimaryPart = jetpackClone.Core jetpackClone.Parent = player jetpackClone:moveTo(player.Torso.Position + player.Torso.CFrame.lookVector * -5) local weld = Instance.new("Motor6D") weld.Parent = jetpackClone.Core weld.Part0 = jetpackClone.Core weld.Part1 = player.Torso 22 Answers
The way to fix this is quite simple.
Like Ahmad said, moveTo is used for models that doesn't have a primary part. But it is not only that.
One thing that Ahmad forgot is that 'lookVector' is not a CFrame, it is a Vector3 instead.
In this fragment, you did
moveTo(player.Torso.Position + player.Torso.CFrame.lookVector * -5) That would be fine, if you didn't use a numerical value with Vector3's. To fix this, instead, your code should be
local player = script.Parent local jetpack = game.ReplicatedStorage.Jetpack; local jetpackClone = jetpack:Clone(); jetpackClone.PrimaryPart = jetpackClone.Core; jetpackClone.Parent = player; -- Is the 'Player' a Player, or a character?? local weld = Instance.new("Weld", player.Torso) -- We use 'Weld' here, instead of Motor6D weld.Part1 = jetpackClone.Core; weld.Part0 = player.Torso; weld.C0 = CFrame.new(0, 0, -5); -- We use the C0 property of Weld's That should do it for welding the jetpack to your torso. Though, I would check if the CFrame is correct in it, I am not sure if it is or not, but if the jetpack appears in front of your torso, then replace weld.C0 = CFrame.new(0, 0, -5) to weld.C0 = CFrame.new(0, 0, 5).
Hope my answer helps!
moveTo is used for models that doesn't have a primary part. Which can be inaccurate. Instead use :SetPrimaryPartCFrame() also u were adding Position+CFrame(it would cause an error did u check output?)