As the title suggests how would one get a model to position perfectly on top of a part? you can see the model sets perfectly on top of the part when I’ve manually placed it I’ve made the model scale to the size of the plate and when it scales up the offset becomes more and more how do I get it to position on top of the plate no matter the size of the model with 100% accuracy?
how it looks when I run my code
I’ve looked far and wide on here, some posts said to use GetExtentsSize and divide it by half for perfect positioning and welp, it’s not working for me. Any help at all is appreciated thank you.
Code I have so far
--Variables
local plate = script.Parent.Parent
local electric_fence = script.Parent:FindFirstChild("FenceModel")
local primary = electric_fence.PrimaryPart
local primary_cframe = primary.CFrame
local scale = plate.Part.Size.X / 12
local electric_fence_size = electric_fence:GetExtentsSize()
--Resizes electric fence children to scale with plate size
for _,part in pairs(electric_fence:GetChildren()) do
if part ~= primary then
part.Size = part.Size * scale
part.CFrame = (primary_cframe + (primary_cframe:inverse() * part.Position * scale))
end
end
--Variables Position fence unnder plate
electric_fence:SetPrimaryPartCFrame(plate.Part.CFrame:ToWorldSpace(CFrame.new(0, plate.Part.Size.Y - electric_fence_size.Y/2, 0)))