This is a script that is supposed to give you a part on your head and weld it on to it
function GiveHat()
if HatOn == False then
local I = Instance.new("Part")
local D = Instance.new("Decal")
local T = script.Parent.Parent.Parent.Parent:FindFirstChild("Head")
D.Parent = I
D.Texture = "http://www.roblox.com/asset/?id=149397688"
I.Parent = T
I.CanCollide = false
I.Size = Vector3.new(0.2,1,0.2)
print("Part Created")
--Weld I and T
I.Position = T.Position + Vector3.new(0,1,0)
script.Parent.HatOn = true
else
local T = script.Parent.Parent.Parent.Parent:FindFirstChild("Head")
HatOn = false
T.I:Destroy()
end
end
script.Parent.MouseButton1Down:connect(GiveHat)
This is the exact code I'm having trouble with. Everytime I run it, it always says "attempt to index local "T"(a nil value)" and yes, script.Parent.Parent.Parent.Parent is the player.
also I don't know how to weld the 2 parts together

1 comment
script.Parent.Parent.Parent.Parent is the player name, i checked but it still doesnt work