How do you make a part follow a player effectively without it being slower and delayed

theres a problem ive been trying to figure out, how to games that have pet or any part just stick to the player with out being delayed i really cant explain well because its hard to but heres the script

task.spawn(function()
			while task.wait() do
				slash.CFrame = humanoidRootPart.CFrame * CFrame.new(0, 0, -3) * CFrame.Angles(0,math.rad(180),0)
			end
		end)
2 Likes

2 Likes

The image is a little bit confusing. Which direction is which the player is facing

2 Likes

the player is facing forward, like walking straight

2 Likes

bascily, the part gets delayed behind the player

2 Likes

I believe that these games weld it to the actual player model instead of having it follow the player with a script.

What I did here was put a WeldConstraint inside the object I want to weld and set the Part0 to the object and Part1 to the HumanoidRootPart. Make sure the object is unanchored or it won’t work.


3 Likes

Here is a really rough idea:

  • Get your part/model and pivot to the humanoidRootPart Cframe.
  • then you create two attachments, one for the players character and then one for your part.
  • Create two new instances called AlignPosition and AlignOrentiation
  • Now modify these instances with their forces and responsiveness. Making sure both Attachment0’s is the part attachment and both Attachment1’s is the character attachment (you made in the second bullet point)

It should work roughly, you can then additionally use TweenService to animate the part! You should look into AlignPosition and AlignOrentiation

3 Likes

If you want to use code instead of welding it to the character model, you would have to use a PreSimulation event with RunService instead of using task.wait() . Using PreSimulation makes the code run every frame so you get 0 delay.

3 Likes