I'm trying to make it so that when you press a button a block (Part1) becomes visible and collision is on. I've got it working for one part, but I want to be able to make a variable hold more than one part.
For example, two parts that make up a bridge. (Part 1 and Part 2). Instead of writing each individual part name, I want to be able to type a variable like "bridge" that will include all the parts.
I would union it however, in my build the Part 1 and Part 2 are different materials.
Here's all my code:
db = false
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild ("Humanoid") then
local invisible = workspace.Part1
if db == false then
db = true
script.Parent.Material = "Plastic"
invisible.Transparency = 0
invisible.CanCollide = true
wait(5)
invisible.Transparency = 1
invisible.CanCollide = false
script.Parent.Material = "Neon"
db = false
end
end
end)

2 comments
Thank you so much! This is really helpful since I'm still learning.
I've tested this out and learned a bit from it but I'm still struggling. This goes through each part and runs the script for each part in my table one at a time. How can I use a table in a script where the parts will go in unison? For example, in my script I want the collision and transparency to go from true / 0 to false / 1 but I want all parts in my table to do this at the same time.