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

How to make block disappear when player touched it?

So when the player touches a certain block it disapears.

1 answer

✓ Accepted answer

When making things like this, there are various ways to do it, and I think this is the easiest and best way. Using a for loop, you can make the brick fade out, or you can just destroy it by using the :Destroy() or :Remove() events.

Keep in mind this will only work if your hierarchy is as such:

*Part > *Script

Well, this is the script I have made.

script.Parent.Touched:connect(function(hit) -- connects function with script.Parent.Touched
	if hit.Parent.Humanoid then -- checks if it's an NPC or a player.
		if script.Parent.Transparency < 1 then -- checks if the transparency is less than one
			for i = 0, 1, 0.1 do
				
				-- somewhat intermediate method --
				
				script.Parent.Transparency = i --this makes it fade
				script.Parent.CanCollide = false --this makes it so you can go through it
				
				wait(0.1) -- how fast the fade is, you can change this.
			end	
			script.Parent.Destroy()
		end
			-- alternate method--	
		
		script.Parent:Destroy() -- simply destroys the brick
	end
end)

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