Okay so,
i know this may sound really simple but,
I have a theatre game and it has a stage with different sets, I currently change it all manually but I think I can get a script to do it for me.
So, I want a button that you can click that makes a model go transparent and you can walk thru it, like it is not there (i think that is cancollide false). And then if you click the button again, it is back (non-transparent and cancollide true)
Yea hope that you can understand!
cheers!
Oh just put a "ClickDetector" in your part and add a script inside the "ClickDetect" containing this code:
1 | script.Parent.MouseClick:Connect( function () |
2 | local part = script.Parent.Parent |
3 |
4 | part.Transparency = 1 |
5 | part.CanCollide = false |
6 | end ) |
however, if you want it to be opened and closed use this one:
01 | local open = false -- a variable to define if its open or not |
02 |
03 | script.Parent.MouseClick:Connect( function () |
04 | local part = script.Parent.Parent |
05 |
06 | if open then -- if open or if open == true |
07 | open = false -- we set it to false so it doesnt do the same code |
08 |
09 | part.Transparency = 1 |
10 | part.CanCollide = false |
11 | else -- you prob get this one lol |
12 | part.Transparency = 0 |
13 | part.CanCollide = true |
14 | end |
15 | end ) |
hope I helped
This can be simply solved by inputting a ClickDetector inside of your target part. Next, in that same very part, insert a Script. Then, type the following code:
1 | script.Parent.ClickDetector.MouseClick:Connect( function () |
2 | script.Parent.Transparency = 1 |
3 | script.Parent.CanCollide = false |
4 | end ) |
I have made a quick video on how to do this, and I will also give you the roblox game as I published it to roblox, and you will be able to get a copy of the game if you click the 3 dots next to the game title. Also where it says model = just put where your model is in the explorer. for e.g.
1 | game.workspace.House.Jimmy |
or something like that.
Video: https://youtu.be/JycJWLYSXGI
Game: https://www.roblox.com/games/6738511109/Model-with-Button