How to make a part float above the players head at all times?

My goal is similar to the goal in this post: Make revolving parts around a character

I’m trying to create a script that allows for a Part(placeholder) to float above the players head and be able to follow/keep up with the player.

All help/answers is appreciated!

2 Likes

You can use a WeldConstraint to weld a part onto the player’s Head / HumanoidRootPart or just constantly update the part’s CFrame to match the Head / HumanoidRootPart’s CFrame with an offset.

1 Like

Can’t use a weld, I can only use CFrame.

Hmm this reminds me of when I was creating my king of the hat game I needed to do the same thing and I never really came up with a good solution, but basically I yoinked a pet script and adjusted the cframe so it was above the players head or at least I yoinked the part that makes the pet follow.

So my solution probably isn’t the best, but here’s what I did pretty much

local function follow(Hat, V2, c)
		local bp = Instance.new("BodyPosition")
		bp.P = 90000 --I really never understood what this did, but feel free to adjust it
		bp.Parent = Hat
				
		coroutine.resume(coroutine.create(function()
			while wait() do
			 bp.Position = c.Head.Position + Vector3.new(0,1,0)
		end))  	
end

edit: I assume you know, but Hat would be your part and then the Vector3 you can adjust that to what you want

For pets, you can just use RocketPropulsion. I believe they’re much more cleaner since you’re not really updating a property constantly. (Although I’ve never really tried it out myself).

oooh this would have been good to know lmao yeah that code was from a few months ago when I didn’t really know as much as I do now, but I mean it did what I wanted it to do so ye know ¯_(ツ)_/¯

1 Like

Try using an AlignPosition constraint. Otherwise, messing around with lerping CFrames could be a good option, but using physics constraints saves a lot of time and the performance difference is likely negligible. Not to mention this is quite easily customisable too.

1 Like

I’ll try all of the suggestions now and mark the one that works the best as the solution :slightly_smiling_face:.