How to Make a Button that Makes a Part Disappear
Download – Disappear Script and Model
How To – Make a Button that Makes a Part Disappear
What’s up everyone welcome to buzzygames, my name is BuzzyGamesBeth and today I’ll be teaching you how to make a button that makes a part disappear!
- I have this super incredibly basic button that I made in under like two seconds. It’s just composed of two parts, the red part is going to be the button that I click and then i’m gonna go ahead and add this part right over here. So this is the part that I want to make disappear anytime I click on that red button.
- The part that I added into that, I want to make disappear i’m just going to go ahead and rename that part to let’s do “disappear” pretty simple. So i’m renaming this just so that I can reference this later inside of my script that i’ll be adding inside of my button
- Inside our button let’s go ahead and add a click detector, as well as a script. Go ahead and delete our print statement we really don’t need that right now. What i’m going to do is create our variables so that is referencing the part that we want to make disappear which is simply game.workspace.disappear. We’re going to make a variable for our click detector and then we’re going to make a variablefor the switch for either it’s on or if it’s off.
- Okay so i’m going to go ahead and write a function where player is our parameter. I’m going to if not switch then so we’re going to code it where once the switch is on or off then the part is either going to be transparent or not transparent and such like that. What i’m going to start off with is part.transparency = equal to one part can collide is equal to false if switch is equal to true. So if it’s on then the transparency of a part is going to be equal to one and then cancollide is equal to false, but if the switch is equal to false then transparency is equal to zero and cancollide is going to equal true. Meaning if it’s off then we can see it, but if it’s on then we can’t and we’re going to go ahead and call our function. That’s it we’re done sweet!
- Go ahead and hop inside of our game, it should work the moment of truth let’s go ahead and see if I click on the button, the part disappears!