Hello, recently, one of my scripts has completely broken. It uses CFrame toObjectSpace and Inverse to move multiple parts (Inside an accessory, so SetPrimaryPartCFrame isn’t possible). Instead of the expected behaviour, it breaks up my models.
It’s causing lots of issues. I really cannot figure out why, as it was working fine yesterday.
I’ve found a solution. It’s only occurring if I anchor the parts affected. It’s really odd. I’ll make a repro soon.
Edit:
local ShopModules = {}
for _,v in pairs(workspace.Shops:GetChildren()) do
ShopModules[v.Name] = require(v.Info)
local TM = ShopModules[v.Name]
for i,Item in pairs(TM.ItemVisuals) do
local NewItems = game.ReplicatedStorage.Items[Item.Type][Item.Name]:Clone()
NewItems.Handle.Anchored = true
-- oh how do i move all the parts
local Offset = v.ItemVisuals[tostring(i)].CFrame:toObjectSpace(NewItems.Handle.CFrame)
for _,x in pairs(NewItems:GetDescendants()) do
if x:IsA("BasePart") then
x.Anchored = true
if Item.Type == "Collector" then
x.CFrame *= Offset:Inverse() * CFrame.Angles(math.rad(90),0,math.rad(180))
else
x.CFrame *= Offset:Inverse() * CFrame.Angles(0,math.pi,0)
end
end
end
NewItems.Parent = v.ItemVisuals
end
end
This code has the issue.
local ShopModules = {}
for _,v in pairs(workspace.Shops:GetChildren()) do
ShopModules[v.Name] = require(v.Info)
local TM = ShopModules[v.Name]
for i,Item in pairs(TM.ItemVisuals) do
local NewItems = game.ReplicatedStorage.Items[Item.Type][Item.Name]:Clone()
NewItems.Handle.Anchored = true
local Offset = v.ItemVisuals[tostring(i)].CFrame:Inverse() * NewItems.Handle.CFrame
for _,x in pairs(NewItems:GetDescendants()) do
if x:IsA("BasePart") then
if Item.Type == "Collector" then
x.CFrame *= Offset:Inverse() * CFrame.Angles(math.rad(90),0,math.rad(180))
else
x.CFrame *= Offset:Inverse() * CFrame.Angles(0,math.pi,0)
end
end
end
NewItems.Parent = workspace
end
end
This code does not
The accessories being moved look like this:
They are welded manually with WeldConstraints.