Roblox Studio Tutorials - December 30, 2021

How to Destroy a Part Pressing “E”


Buzzy Beth


Download – Destroy Script

How To – Destroy a Part Pressing “E” | Proximity Prompts

What’s up everyone welcome to buzzygames, my name is BuzzyGamesBeth and today I’ll be teaching you how to destroy a part pressing “E”!

  • Using proximity prompts is probably one of my favorite things ever since roblox added
  • So now we’re just going to go ahead and create a part and this is the part that I want to destroy and inside of our part let’s go ahead and add a proximity prompt.
  • You can change the action text to whatever you want. This action text is when you’re close to it this text is going to appear.
  • Let’s change the hold duration to 0.5 seconds. You can change the keyboard keycode but i’ll keep it as “e” as the default, cool!
  • Inside of our proximity prompt let’s go ahead and add a script, we’re going to do script.parent so the proximity prompt is the parent of the script, that’s what it means when we do something dot parent! It’s the parent of whatever it’s attached to.
  • This can be script.parent.triggered:connect(function) and then we only have one more line of code left which is going to be script.parentdot parent colon destroy so essentially what’s happening is anytime we trigger the proximity prompt then our part is going to be destroyed and that’s it!
  • Pretty simple right? So now if we hop into our game and then we run to our part and we hold “e” our part disappears!