I am trying to make a tool, that makes objects smaller, which its doing what its supposed to do so far, except for the fact everything loses its rotation and original position.
Here is what’s happening:
https://gyazo.com/c98e8925ec3aca3771495c2ff3e16839
I have tried searching the internet on how to resize models with scripts, and found a thread on dev forums which shows how to do so, everything works in that script except the rotation gets messed up.
function ConstructionTool:CreateLoop(PlayerTable)
--Destroy welds
for _,object in pairs(PlayerTable.Item:GetDescendants()) do
if object:IsA('Weld') or object:IsA('ManualWeld') or object:IsA('WeldConstraint') then
object.Part0.Anchored = true
object.Part1.Anchored = true
object:Destroy()
elseif object:IsA("CFrameValue") then
object:Destroy()
end
end
-- resizing [MAIN]
return RunService.Heartbeat:Connect(function()
--Scale BaseParts
for _,object in pairs(PlayerTable.Item:GetDescendants()) do
if object:IsA('BasePart') then
object.Size = object.Size*0.999
local distance = (object.Position - PlayerTable.Item.PrimaryPart.CFrame.p)
local rotation = (object.CFrame - object.Position)
object.CFrame = (CFrame.new(PlayerTable.Item.PrimaryPart.CFrame.p + distance*0.999) * rotation)
end
end
end)
end