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

How do I make something disapear when someone touches it?

I used to know this, but its been a long time since ive programmed, so is it like

function onTouch()
game.Worksapce.Parent:Destroy()

I really wanna know

2 answers

Good try attempting to script it yourself. Indeed, both lines are correct, but you forgot quite a lot.

script.Parent.Touched:connect(function(player) --So, the brick is touched and the person touching it is now called "player"
	Humanoid = player.Parent:FindFirstChild("Humanoid") --Searches for a humanoid
	if Humanoid ~= nil then --If the humanoid is present (Basically checks for a player) then...
		script.Parent:Destroy() --Completely removes the object from the game
	end --Ends the if statement
end --Ends the function
--Put this in the object that gets destroyed. Otherwise, this may not work properly

I don't know if this is what you are wanting, but this may work for you.

-- You must put this in a part
function onTouched(hit)
	if hit.Name == "Part" then --Change this to what ever the part is called fyi :P
	hit:remove() 
end
end

script.Parent.Touched:connect(onTouched)

You have to put this script in a part.

Example When you step on the part i will call "P1" It will destroy a different part i will call "P2" So, the the script should be in "P1" The script should look like:

-- You must put this in a part
function onTouched(hit)
	if hit.Name == "P2" then --Change this to what ever the part is called fyi :P
	hit:remove() 
end
end

script.Parent.Touched:connect(onTouched)

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