Help! My morph welding script aligns wrong the gear based on its position

The misalignment is based on the character’s position it works on 0,0,0 but doesnt work on like -3725,267,125
image
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

Could someone please help me with it?

Maybe try adding an invisible HumanoidRootPart to your items.

Then just match the CFrames when Welding:

MyPart.HumanoidRootPart.CFrame = TargetCharacter.HumanoidRootPart.CFrame

Or Head, or whatever Part from a Character you want to line up with.

I add a part called ‘Middle’ Its basically the same i just clone the limbs from the rig and put them inside the gear and delete every child they have

hat.Parent = l
l.CFrame = hat.PrimaryPart.CFrame

image

Can you give more details on what you mean by misalignment?

By misalignment i mean misplacement for example:
Lens moving forward when they were supposed to be in the googles

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?

Im saying that if the morph that im trying to equip is too far from the position of 0,0,0 the gear (the hat for example) misplaces

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.

I just know that it does.

So uhhh there isnt any possible fix that you would know?

Wish I did know.

I couldn’t find one back then (a few months ago.)

Maybe repost with a new title.

Why do things go wonky if they are too far from (0,0,0)

1 Like

Alright thank very much

Only 10 * 3 Characters