Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Remove hat on touch script?

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

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.