Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I make parts appear/disappear using a custom command?

Asked by 5 years ago
Edited 5 years ago

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'.

1function onChatted(msg, speaker)
2    local source = string.lower(speaker.Name)
3    msg = string.lower(msg)
4    if msg == "!show" then
5 
6    end
7end

2 answers

Log in to vote
0
Answered by
3132750 45
5 years ago

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
02local parts = {script.Parent.part1,script.Parent.part2,script.Parent.part3}
03--this loop goes through the parts in the list and hides them
04for _, part in ipairs(parts) do
05    part.Transparency = 1
06    parts.canCollide = false
07end
08--this waits 5 secounds before it shows them again
09wait(5)
10--this loop goes through the parts in the list and shows them
11for _, part in ipairs(parts) do
12    part.Transparency = 0
13    parts.canCollide = true
14end
Ad
Log in to vote
0
Answered by 5 years ago

You could use the Destroy() function say whatever your're trying to do to cause the brick to break try after the then

Part:Destroy() else Part = Instance.new("Part")

Answer this question