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

Help me with the touch event!! Can u help me?

How can i make a part that if u touch other part disappear

3 answers

This script is about where if you touch Part1, part2 will "disappear" (I'm assuming you mean go transparent).

local part2 = game.Workspace.part2 --Replace Part2 with the name of the part that you want to disappear

function onTouched()
part2.Transparency = 1 --Or do part2:Destroy() if you want it completely removed
end

script.Parent.Touched:Connect(onTouched)

Like I said, you need to be more specific and try to include code snippets. This wont work for models, otherwise you'd have to include every single piece in the script.

Hope this helps!

The above script is if you want to completely remove it

local PART2NAME= game.Workspace.PART2NAME--Replace Part2 with the name of part2

function onTouched()
PART2NAME:Destroy()
end

script.Parent.Touched:Connect(onTouched)

The below script is if you want to make it invisible

local PART2NAME= game.Workspace.PART2NAME--Replace Part2 with the name of part2

function onTouched()
PART2NAME.transparency = 1
end

script.Parent.Touched:Connect(onTouched)

Please try to add your coding attempt(s) so I can help you more next time.

local part = game.Workspace.Part -- Get the part that you want 

part.Touched:Connect(function() -- if someone touched the part then connect to this function
	-- Everything here inside this function is going to run after the part is touched
						
	part.Transparency = 1 -- the part will disappear, if you want  to remove it completely then write part.Destroy()
end)

Hope this helped

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