Mesh Scale and Offset

I’m not good at describing things, but I’ll do my best.

What I’m attempting to do is make a sort of hat-equip system, with blocks with meshes in them. When what the hat is equipped to is bigger, the mesh needs to get bigger to match the scale. However, when this happens, often times part of the hat’s mesh sinks into what it’s attached to. Or, inversely, if what the hat is attached to shrinks, it often floats above. I’ve tried fixing this with Offset, but that’s often guesswork as well and still floats above the equip region or sinks into the model.

If this helps at all this was an attempt:

hatClone.Mesh.Scale = carToCustomize.Config.HatSize.Value
hatClone.Mesh.Offset = hatClone.Mesh.Offset +, hatClone.Mesh.Scale.X/2, 0)


Try using a meshpart, It solves all of these hitbox issues and the whole “scale won’t match” problem.

1 Like

You’ll want to do some general proportional math. You’d need the designated initialOffset and initialScale from an initial value.

For an example, we’ll pretend we’re talking about a hat that is attached to different sized heads.

For the initial offset, you’ll need to be sure to include any additional offset incurred from the two different part positions, or you’ll need to have the hat part be at the exact same position as the head to solely use meshOffset.

local multiplier = currentHeadSize/initialHeadSize
local desiredOffset = initialOffset*multiplier
local desiredScale = initialScale*multiplier
1 Like