Hello, I have recently had help to extend upon this script, yet it still does not function correctly. By clicking the player should receives a hat from the script, yet the player receives nothing. What may be a possible factor for this reason?
debounce = true
if not script.Parent:findFirstChild("ClickDetector") then
local cd = Instance.new("ClickDetector")
cd.Parent = script.Parent
end
script.Parent.MouseButton1Down:connect(function()
local character = player.Character
if (character:findFirstChild("Humanoid") ~= nil and debounce == true) then
debounce = false
h = Instance.new("Hat")
p = Instance.new("Part")
h.Name = "Hat"
p.Parent = h
p.Position = character:findFirstChild("Head").Position
p.Name = "Handle"
p.formFactor = 0
p.Size = Vector3.new(-0,-0,-1)
p.BottomSurface = 0
p.TopSurface = 0
p.Locked = true
script.Parent.Mesh:clone().Parent = p
h.Parent = hit.Parent
h.AttachmentPos = Vector3.new(0,0.4,-0.025)
wait(5) debounce = true
end
end)
