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

How to make this only work with humanoids?

This script is supposed to remove it's parent when someone touches it. As of now, it removes itself when anything touches it. I was wondering if it was possible to make it remove itself ONLY when a humanoid touches it.

function touch()
	script.Parent:remove()
end

script.Parent.Touched:connect(touch)

1 answer

script.Parent.Touched:connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		hit:Destroy()
	end
end)

This will destroy anything that touches it as long as there is a object called Humanoid inside the part's parent

This discussion is preserved as it was. New answers, comments, and votes are closed.