How do i make this ''crate'' go back to normal once it's function is actually done in the game?
Hi, i've made model and inside that model there is a crate with some parts in it that make the crate (18 parts) and a humanoid (stats are Maxhealth = 100, Health = 100) and a script. So the idea is, if the crate's health goes to 0 or lower the parts (17 parts) will get unanchored, leaving 1 part and that's called the ''center''. That part will be transparent and uncancollide. Now what the problem is, is that i can't find a way to redo that. So if the parts get unanchored and the center goes transparent and uncancollide, it won't return later back to normal how it was. Can someone help me? Here is the script. Oh, i just started scripting so there might be some things i did in the script that are stupid and could be written shorter or something. If you could teach me a way to do that it would be awesome! Thanks :D
02 | script.Parent.Humanoid.HealthChanged:connect( function () |
03 | if script.Parent.Humanoid.Health < = 0 then |
04 | b.Center.Transparency = 1 |
05 | b.Center.CanCollide = false |
06 | b.Part 1. Anchored = false |
07 | b.Part 2. Anchored = false |
08 | b.Part 3. Anchored = false |
09 | b.Part 4. Anchored = false |
10 | b.Part 5. Anchored = false |
11 | b.Part 6. Anchored = false |
12 | b.Part 7. Anchored = false |
13 | b.Part 8. Anchored = false |
14 | b.Part 9. Anchored = false |
15 | b.Part 10. Anchored = false |
16 | b.Part 11. Anchored = false |
17 | b.Part 12. Anchored = false |
18 | b.Part 13. Anchored = false |
19 | b.Part 14. Anchored = false |
20 | b.Part 15. Anchored = false |
21 | b.Part 16. Anchored = false |
22 | b.Part 17. Anchored = false |
23 | b.Part 18. Anchored = false |