How to make a part follow you

Hello! I am trying to make an effect like this where the balls follow you around until you release them. However, mine just stay there without moving. Here’s my code:

			local demonfolder = Instance.new("Folder", workspace)
			demonfolder.Name = Model.Name..":DemonFireballs"
			local player = game.Players[Model.Name]
			
			local fire1 = Assets.FireStorm:Clone()
			local cfv1 = Instance.new("CFrameValue", fire1)
			cfv1.Value = CFrame.new(math.random(-5,5), math.random(0,5), math.random(1, 5))
			fire1:SetPrimaryPartCFrame(Model.HumanoidRootPart.CFrame * cfv1.Value)
			fire1.Parent = demonfolder
			fire1.Name = "FireStorm1"
			
			local fire2 = Assets.FireStorm:Clone()
			local cfv2 = Instance.new("CFrameValue", fire2)
			cfv2.Value = CFrame.new(math.random(-5,5), math.random(0,5), math.random(1, 5))
			fire2:SetPrimaryPartCFrame(Model.HumanoidRootPart.CFrame * cfv2.Value)
			fire2.Parent = demonfolder
			fire2.Name = "FireStorm2"
			
			local fire3 = Assets.FireStorm:Clone()
			local cfv3 = Instance.new("CFrameValue", fire3)
			cfv3.Value = CFrame.new(math.random(-5,5), math.random(0,5), math.random(1, 5))
			fire3:SetPrimaryPartCFrame(Model.HumanoidRootPart.CFrame * cfv3.Value)
			fire3.Parent = demonfolder
			fire3.Name = "FireStorm3"
			
			local fire4 = Assets.FireStorm:Clone()
			local cfv4 = Instance.new("CFrameValue", fire4)
			cfv4.Value = CFrame.new(math.random(-5,5), math.random(0,5), math.random(1, 5))
			fire4:SetPrimaryPartCFrame(Model.HumanoidRootPart.CFrame * cfv4.Value)
			fire4.Parent = demonfolder
			fire4.Name = "FireStorm4"
			
			local fire5 = Assets.FireStorm:Clone()
			local cfv5 = Instance.new("CFrameValue", fire5)
			cfv5.Value = CFrame.new(math.random(-5,5), math.random(0,5), math.random(1, 5))
			fire5:SetPrimaryPartCFrame(Model.HumanoidRootPart.CFrame * cfv5.Value)
			fire5.Parent = demonfolder
			fire5.Name = "FireStorm5"
	
			for i, v in pairs(demonfolder:GetChildren()) do
				Model.HumanoidRootPart:GetPropertyChanedSignal("CFrame"):Connect(function()
					v:SetPrimaryPartCFrame(Model.HumanoidRootPart.CFrame * v.CFrameValue.Value)
				end)
			end

There are no errors. Thanks for your help :smiley:

6 Likes

You are better off using Welds to do this instead. :SetPrimaryPartCFrame() can be laggy.

2 Likes

From the video it looks like they are just welded to the character. Have you tried that?

2 Likes

Hmm I haven’t really done welding before but I’ll try it

1 Like

It worked! But it only goes in one location which is my humanoid root part: https://gyazo.com/033b32ae44e9349a9857419e772b7324

I tried it with only one ball so this is what I did:

local fire1 = Assets.FireStorm:Clone()
			local cfv1 = Instance.new("CFrameValue", fire1)
			local weld = Instance.new("Weld")
			weld.Part0 = fire1.PrimaryPart
			weld.Part1 = Model.HumanoidRootPart
			weld.Parent = fire1
			cfv1.Value = CFrame.new(math.random(-5,5), math.random(0,5), math.random(1, 5))
			fire1:SetPrimaryPartCFrame(Model.HumanoidRootPart.CFrame * cfv1.Value)
			fire1.Parent = demonfolder
			fire1.Name = "FireStorm1"
2 Likes

You just need to edit the C0 of the weld. For example if you do

weld.C0 = CFrame.new(5, 0, 0) 

that will make the ball be welded 5 studs to the right of the humanoid root part instead of directly in the center, mess with that cframe value and you can get them to the same position as the video you showed

1 Like

To me this looks like a bunch of unnecessary code since roblox has already made stuff to do this for you. I think there r constraints called ‘AlignPosition’ for more binding following balls,or if u want some drag use body position. if I missunderstood the question then sort but its like midnight and im about to sleep

1 Like

I have created something that resembles what you have using the new BodyMovers that @anon92559147 was mentioning, you can find the repo here:

https://gyazo.com/70d145070ed25b59dee237548bace965

game.Players.PlayerAdded:Connect(function(Player)
   Player.CharacterAdded:Connect(function(Character)
   	for i,v in pairs(script.Parts:GetChildren()) do
   		local Part = v:Clone()
   		Part.Parent = Character
   		local Attachment1 = Character.HumanoidRootPart:WaitForChild("RootRigAttachment")
   		local Attachment0 = Part:WaitForChild("Attachment1")
   		local AlignPosition = Instance.new("AlignPosition")
   		AlignPosition.Parent = Part
   		AlignPosition.Attachment0 = Attachment0
   		AlignPosition.Attachment1 = Attachment1
   		local AlignOrientation = Instance.new("AlignOrientation")
   		AlignOrientation.Parent = Part
   		AlignOrientation.Attachment0 = Attachment0
   		AlignOrientation.Attachment1 = Attachment1
   	end
   end)
end)

FollowParts.rbxl (18.2 KB)

16 Likes

Hi! This is really cool, thank you. How can you make the item follow you upon equiping a tool or reaching a stat or level for example? I’ve tried so many different combinations I can only get it to give it to a player if you start off with a stat not while playing and reaching a stat or not even when an tool is equiped.

Bro this post was 2 years ago :skull:

Should be fairly simple just look into Body Movers to get the movement and then use a Tool.Equipped event to trigger it.

Im still a beginner. I’ve tried so many edits, I can only get it to work if I start off with a tool equipped or a stat. But I’m still trying, will look into that.