How do i make a script that removes the player's hat when they touch a certain brick?
✓ ANSWER ACCEPTED
Remove hat on touch script?
1 answer
✓ Accepted answer
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)
This discussion is preserved as it was. New answers, comments, and votes are closed.
