make "free children" actually work

since it was erroring most of the time.
not sure why it's aborting early, but it works somewhat
This commit is contained in:
Techbot121 2023-05-01 17:21:25 +02:00
parent 7ff355c47c
commit f9bbbb8606

View File

@ -301,17 +301,29 @@ pace.AddTool(L"scale this and children", function(part, suboption)
end)
pace.AddTool(L"free children from part" ,function(part, suboption)
if part:IsValid() then
local grandparent = part:GetParent()
local parent = part
for _, child in ipairs(parent:GetChildren()) do
child:SetAngles(child.Angles + parent.Angles)
child:SetPosition(child.Position + parent.Position)
child:SetAngleOffset(child.AngleOffset + parent.AngleOffset)
child:SetPositionOffset(child.PositionOffset + parent.PositionOffset)
child:SetParent(grandparent)
end
local children = part.Children
if #children == 0 then
Derma_Message(L"this part has no children...", L"free children from part", "ok")
return
end
Derma_Query(L"this process cannot be undone, are you sure?", L"free children from part", L"yes", function()
if part:IsValid() then
local grandparent = part:GetParent()
if grandparent == NULL then
grandparent = part:GetRootPart()
end
local parent = part
for _, child in ipairs(children) do
if child.BaseName ~= "base" and parent.BaseName ~= "base" then
child:SetAngles(child.Angles + parent.Angles)
child:SetPosition(child.Position + parent.Position)
child:SetAngleOffset(child.AngleOffset + parent.AngleOffset)
child:SetPositionOffset(child.PositionOffset + parent.PositionOffset)
end
child:SetParent(grandparent)
end
end
end, L"no", function() end)
end)
pace.AddTool(L"square model scales...", function(part, suboption)
@ -790,4 +802,4 @@ pace.AddTool(L"copy from faceposer tool", function(part, suboption)
flex:SetWeight(weight)
end
end
end)
end)