I'm looking for a way to make a few parts appear after using a custom command, then disappear after using the command again. I'm relatively new to lua and roblox game development so any sort of advice would help. Thanks.
Here's what I have for the command part, not sure on what to put after the 'then'.
1 | function onChatted(msg, speaker) |
2 | local source = string.lower(speaker.Name) |
3 | msg = string.lower(msg) |
4 | if msg = = "!show" then |
5 |
6 | end |
7 | end |
You would have to make an array with all the parts you want to appear and disappear. Then, a for loop to set transparency and canCollide.
Here is what the code should look like
01 | --this defines the list of parts you want to hide and show |
02 | local parts = { script.Parent.part 1 ,script.Parent.part 2 ,script.Parent.part 3 } |
03 | --this loop goes through the parts in the list and hides them |
04 | for _, part in ipairs (parts) do |
05 | part.Transparency = 1 |
06 | parts.canCollide = false |
07 | end |
08 | --this waits 5 secounds before it shows them again |
09 | wait( 5 ) |
10 | --this loop goes through the parts in the list and shows them |
11 | for _, part in ipairs (parts) do |
12 | part.Transparency = 0 |
13 | parts.canCollide = true |
14 | end |
You could use the Destroy() function say whatever your're trying to do to cause the brick to break try after the then
1 |
Part:Destroy() else Part = Instance.new("Part")