Hi, I have been trying to come up with a way to create this into a click hat giver rather than a ontouch hat giver. I have added a click detector, what would I need to do to convert this into a click giver?
debounce = true function onTouched(hit) if (hit.Parent: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 = hit.Parent: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 script.Parent.Touched:connect(onTouched)
I am have not tested this, as I am not on a computer with ROBLOX Studio downloaded. If this works, then please accept this answer, if not, please leave a reply with the output.
debounce = true if not script.Parent:findFirstChild("ClickDetector") then local cd = Instance.new("ClickDetector") cd.Parent = script.Parent end script.Parent.ClickDetector.MouseClick:connect(function(player) 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)