I don’t fully understand how to use it. I tried to clone the original model and reflect all the parts relative to original parts but it turns out weird
weapon - original weapon
cam = workspace.CurrentCamera
-- run.RenderStepped
weapon:PivotTo(cam.CFrame * some_other_cframes)
local function GetReflectedCFrame(CF, MirrorCFrame)
local X, Y, Z, R00, R01, R02, R10, R11, R12, R20, R21, R22 = MirrorCFrame:ToObjectSpace(CF):GetComponents()
-- Reflect along X/Y plane (Z axis).
local Reflection = CFrame.new(
X, Y, -Z,
-R00, R01, R02,
-R10, R11, R12,
R20, -R21, -R22
)
local ReflectedCFrame = MirrorCFrame:ToWorldSpace(Reflection)
return ReflectedCFrame
end
local mirror_cframe = cam.CFrame * CFrame.new(0, 0, 0) * CFrame.Angles(0, math.rad(-90), 0)
local mirror_vm = cam:FindFirstChild('mirror_vm')or weapon:Clone()
mirror_vm.Parent = cam
mirror_vm.Name = 'mirror_vm'
for _, v in mirror_vm:GetChildren()do
if v:IsA('BasePart')then
if weapon:FindFirstChild(v.Name)then
v.CFrame = GetReflectedCFrame(weapon[v.Name].CFrame, mirror_cframe)
end
end
end
for _, v in mirror_vm:GetChildren()do
if v:IsA('BasePart')then
if weapon:FindFirstChild(v.Name)then
v.CFrame = GetReflectedCFrame(weapon[v.Name].CFrame, mirror_cframe)
end
end
end