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

Remove hat on touch script?

Asked by 10 years ago

How do i make a script that removes the player's hat when they touch a certain brick?

1 answer

Log in to vote
1
Answered by 10 years ago

Sounds a bit like a request but a good place to start would be using events such as

brick = script.Parent -- or wherever
brick.Touched:connect(function(part) -- Touched function returns the part that touched the brick.
    head = part.Parent.Head -- variable stores the part's parent (the character) then their hat.
    parts = head:GetChildren() -- Makes a table of all the parts in the head
    for i,v in pairs(head) do -- iterates through the children of the head
        if v:IsA("Hat") then -- if a hat is found the hat is removed.
            v:Destroy()
        end
    end
end)
Ad

Answer this question