Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you make a click detector give you a hat? [closed]

Asked by
Moosee 62
10 years ago

Hellu, I'm trying to make it so that when you click the hat you want. Then you can click it on your head. Like when you click the hat it goes on your head.

I made a script, but it doesn't work. Why?

if ClickDetector then

    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 = "Headphones"
        p.Parent = h
        p.Position = hit.Parent:findFirstChild("Head").Position
        p.Name = "Handle" 
        p.formFactor = 0
        p.Size = Vector3.new(2, 1, 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.3, 0)
        wait(5)
        debounce = true
    end
end

script.Parent.Touched:connect(onTouched)
end

Closed as Not Constructive by User#2

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?