The misalignment is based on the character’s position it works on 0,0,0 but doesnt work on like -3725,267,125
On the right the gear should be alligned like on the left but the lens are misalligned
local PreCFrame = player.Character.HumanoidRootPart.CFrame
for i,e in pairs(script.Parent.Parent.Parent.Parent:GetChildren()) do-- looping through models
local l = player.Character:FindFirstChild(e.Name)
if e.Name ~= script.Parent.Parent.Parent.Name then
if l:IsA("Part") then
if l:FindFirstChild(l.Name) then l:FindFirstChild(l.Name):Destroy() end
if l:FindFirstChild("Weld") then l:FindFirstChild("Weld"):Destroy() end
if e.Name ~= script.Parent.Parent.Parent.Name then
local hat = e:Clone()
local weld = Instance.new("Weld")
weld.Part0 = l
weld.Part1 = hat.PrimaryPart
weld.Parent = l
for i,r in pairs(hat:GetChildren()) do -- looping through hat parts
r.Anchored = false
r.CanCollide = false
r.CanTouch = false
r.Massless = true
local weld = Instance.new("Weld")
weld.Part0 = hat.PrimaryPart
weld.Part1 = r
weld.C0 = hat.PrimaryPart.CFrame:Inverse()
weld.C1 = r.CFrame:Inverse()
weld.Name = r.Name
weld.Parent = hat.PrimaryPart
end
hat.Parent = l
l.CFrame = hat.PrimaryPart.CFrame
else
warn("Woopsy check the line 277 if the welds dont work!")
end
player.Character.HumanoidRootPart.CFrame = PreCFrame
end
end
end
ReplicatedStorage.Remotes.Outfit.PromptWearNormalHats:FireClient(player)
wait(5)
debounce[player.Character] = false
end
If you are using a Head from a Dummy as the PrimaryPart of your Hat then the hat should line up perfectly if your just matching CFrames when welding.
Are you saying a Part within your Model Hat is moving after the Hat is Welded to a Character, or are you saying that if your Player is too far from 0,0,0 the parts of your Hat are moving around?
Yes, I noticed the same when I was trying to create large landscape.
I tested and retested and figured out that anything beyond about 12,000 from world center (0,0,0) starts to go wonky. The farther you go the more crazy the misplacement and distortion grows.
I remember reading about the problem back then but can’t remember why the problem happens.