I'm trying to make a giver that puts a part with a decal on your head. help?
debounce = true
function OnClicked()
if script.Parent.Parent.Parent.Parent:FindFirstChild("Humanoid") ~= nil and debounce == true
then
debounce = false
local h = Instance.new("Hat")
local p = Instance.new("Part")
local d = Instance.new("Decal")
d.Parent = p
d.Texture = "http://www.roblox.com/asset/?id=306287357"
h.Name = "Hat"
p.Parent = h
p.Transparency = 1
p.Position = script.Parent.Parent.Parent.Parent:findFirstChild("Head").Position
p.Name = "Handle"
p.formFactor = 0
p.Size = Vector3.new(0.2,1,1)
p.BottomSurface = 0
p.TopSurface = 0
p.Locked = true
h.Parent = script.Parent.Parent.Parent.Parent
h.AttachmentPos = Vector3.new(0,-0.75,-0.5)
wait(5)
debounce = true
end
end
script.Parent.MouseButton1Click:connect(OnClicked)
Nothing shows up in the output box, but the script doesn't do anything

3 comments
I fixed the (OnTouched), it still does nothing
Is script.Parent a GUI?
No, it is an image button