Make a part follow a moving character

so i have a character that goes along a path using Humanoid:MoveTo and this path has turns

now what i would want to do is have a part that is constantly like 10 studs away from him

so ive tried something like this:

while true do
	task.wait()
	part.Position = char.Position + Vector3.new(0,0,10)
end

now this obviously works, however when the character makes a 90 degree turn, the part is now following on the wrong axis, aka the part doesnt turn with the character

so if anyone has any ideas would be appreciated

1 Like

You could do this instead (changing the CFrame / Coordinate Frame):

part.CFrame = Character.HumanoidRootPart.CFrame + Vector3.new(0, 0, 10)

CFrame is both position and orientation (by that way just in case you didn’t know if you’re adding a position to a CFrame you have to add it with a Vector3).

Edit: Character models don’t have a position (it has a Origin Position but that’s besides the point).

yeah this fixed the rotation problem but i thought wrong and rotation wasnt the only issue

so the actual issue would be that the part would need to be 10 studs in front of him at all times even when he turns

Probably should change the xValue of the Vector3 I told you to add

+ Vector3.new(10, 0, 0) 
-- Or whatever numbers you think are good

not sure what you mean

so when character begins walking it should be: Vector3.new(0,0,10)

but when he turns 90 degrees that would have to be Vector3.new(10,0,0)

part needs to be in front of the character by 10 studs, which by default is 10 on the z axis, but when he turns that needs be 10 on the x axis because thats how it remains in front

Sorry, I’m not the best math… :sweat_smile: (especially at geometry). Uh well I’m unsure maybe someone else can help you with the math.

yeah thanks anyways

post must be at least 30 letters to reply so im just writing this

1 Like