How to create part on top of another based on ray

I was wondering how I could make a part be created on the top of another part based on where the ray was on contact. Please refer to the reference for a visual understanding.

1 Like

Try this

— I’m assuming the ray is fired
local hitpart = ray.Instance
local part = Instance.new(“Part”, workspace)
part.Position = hitpart.Position + Vector3.new(0,5,0) — Adjust offset to your liking
1 Like

I was hoping if there was a way to do it so that the offset is adjusted according to the part’s Y

Ah, then do this

Offset = Vector3.new(0, hitpart.Size.Y / 2 + 3,0)

thanks! Perfect for what I needed it for.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.