The script seems to work fine but When I'm trying to Weld the Hat to the Player's Head it doesn't seem to work. All it does is CFrame Hat into the Players Head But it Doesn't Weld it D: If you can help then I would appreciate it :)
local Player = game.Players.LocalPlayer
local Me = Player.Character
local Mouse = Player:GetMouse()
script.Parent.MouseButton1Click:connect(function()
local Humanoid = Me:FindFirstChild("Humanoid")
if Humanoid then
for i,v in pairs (Me:GetChildren()) do
if v:IsA("Pants") or v:IsA("Shirt") or v:IsA("CharacterMesh") or v:IsA("Hat") then
v:remove()
end
if v:IsA("Part") then
v.BrickColor = BrickColor.new("Mid gray")
end end
print("Recoloured Part and Removed Junk")
for i,v in pairs (Me.Head:GetChildren()) do
if v:IsA("Decal") then
v:remove()
end end
print("Remove Face Decal")
local A = Instance.new("Shirt", Me)
A.Name = "Shirt"
A.ShirtTemplate = "http://www.roblox.com/asset/?id=227899193"
print("Added Shirt")
local B = Instance.new("Pants",Me)
B.Name = "Pants"
B.PantsTemplate = "http://www.roblox.com/asset/?id=188558593"
print("Added Pants")
local C = Instance.new("Decal",Me.Head)
C.Name = "face"
C.Texture = "http://www.roblox.com/asset/?id=133620200"
print("face Added")
local Hat = Instance.new("Hat", Me)
local Handle = Instance.new("Part", Hat)
Handle.Name = "Handle"
Handle.Size = Vector3.new(1,1,1)
local Mesh = Instance.new("FileMesh", Hat.Handle)
Mesh.MeshId = "http://www.roblox.com/asset/?id=13070796"
Mesh.TextureId = "http://www.roblox.com/asset/?id=13070807"
--[[
----------------------------
===>WELDING<===
----------------------------
]]--
Hat.Handle.CFrame = Me.Head.CFrame
local Head = Me:FindFirstChild("Head")
local Weld = Instance.new("Weld")
Weld.Part0,Weld.Part1 = Head,Hat.Handle
Weld.C0 = CFrame.new(0,0.5,0)
Weld.C1 = Me.Head.AttachmentPoint
end end)

2 comments
Thank you !!!!!!!!!!!!
The script works fine it Edit Mode But it doesn't seem to work in-game, when I pressed f9 it came up with a error message saying Players.UserOnly16Characters.PlayerGui.ScreenGui.Frame.ImageButton.Cloth:6: attempt to index upvalue 'Me' (a nil value).