How to find a parts position relative to its parent part

I want to find the position of a part relative to its parent so let’s say that I have a part inside another part but then I move the outer part away. I want it so that even tho the inside part has the same position it’s relative to the outer part so wherever it goes it goes there with the same position.

2 Likes

AlignPosition

1 Like
local base = script.Parent.Parent -- The main part
local target = script.Parent -- The part moving relative to Parent object
local offset = Vector3.new(0, 2, 0) -- The part's offset

base.Changed:Connect(function(change) -- Fires whenever an Instance's properties change
    if change == "Position" then -- If the change was the Part's position
       target.Position = base.Position + offset -- Set position to Base Part's position with given offset
    end
end)