Why doesn't my weld script position the hat correctly?
My weld script is supposed to weld the gasmask to the player positioning it over the player. It's supposed to be just like a hat. Instead it decides that it's okay to position itself behind/in front of my player when I need it to be in the exact location of the players head position. What is going on, and how can I fix this?
local hat= script.GasMask
local weld
04 | local head = c:FindFirstChild( "Head" ) |
07 | for _,v in pairs (hat 2 :GetChildren()) do |
08 | if v:IsA( "Part" ) or v:IsA( "UnionOperation" ) or v:IsA( "MeshPart" ) then |
09 | local weld = Instance.new( "Weld" ) |
11 | local core = v.Parent:FindFirstChild( "Core" ) |
15 | local lol = CFrame.new(head.Position.X,head.Position.Y,head.Position.Z) |
16 | weld.C 1 = v.CFrame:inverse()*lol |
24 | if gM:IsA( "Model" ) then |
25 | gM:SetPrimaryPartCFrame(CFrame.new(head.Position.X,head.Position.Y,head.Position.Z)) |
32 | for _,v in pairs (c:GetChildren()) do |
33 | if v:IsA( "Hat" ) or v:IsA( "Accessory" ) then |
39 | game.Players.PlayerAdded:Connect( function (plr) |
40 | repeat wait() until plr.Character |
43 | weld(hat,plr.Character) |
44 | plr.CharacterAdded:Connect( function (char) |