✓ Accepted answer
You are trying to change a table value, the table value does not have transparency. Think of it like this, a table isn't the variable it just holds the variables kinda like your dresser (if you have one) holds your socks but you can't see the color of the socks until you open the dresser drawer and tell it which sock you want .
You can use a for loop to do this by looping the amount of items in the table and giving the current number it is on a variable... kinda confusing but I'll explain.
Example:
exampletable = {1,2,"a","d",c = 12, q = 20}
for i,v in pairs(exampletable) do
print(v)
end
v is the current "number" it goes to like in an example for statement it is the second value but instead of it being an actual number value it's a variable (this works with getting the children of something to). It will then do this in the pairs of example table (inpairs tutorial: http://wiki.roblox.com/index.php?title=Function_dump/Basic_functions#pairs ) I guess to sum that all up it basically goes through the number of items in a table.
So in your case this should be a simple solution:
a = script.Parent.Parent.Parent.Blocker.a
b = script.Parent.Parent.Parent.Blocker.b
c = script.Parent.Parent.Parent.Blocker.c
d = script.Parent.Parent.Parent.Blocker.d
e = script.Parent.Parent.Parent.Blocker.e
f = script.Parent.Parent.Parent.Blocker.f
g = script.Parent.Parent.Parent.Blocker.g
h = script.Parent.Parent.Parent.Blocker.h
i = script.Parent.Parent.Parent.Blocker.i
j = script.Parent.Parent.Parent.Blocker.j
blockers = {a,b,c,d,e,f,g,h,i,j}
function onClicked()
for i,v in pairs(blockers) do
v.Transparency = 0
v.CanCollide = true
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
If this helped make sure to click Accept Answer
If you have any questions just ask!
8 comments
Hey, it works, but the bricks go away slowly one at a time. Is it possible to fix this?
Anchor them?
You could simply move, or remove, the wait() function so it is not inside of the for loop. Normally, you would have to be cautious when doing this, as it could cause your studio to crash if it creates an infinite loop, but in this case, as the values are all pre-defined, it should be fine.
Thanks for pointing that out iLiminate, I changed the answer because it truly is not necessary
Fixed
@ilim I saw that and changed that.
Thanks for both of your guy's help... You are awesome!
Also, the first 11 lines could probably be rescripted to something like this: blockers = {} for i,e in pairs(script.Parent.Parent.Parent.Blocker.getChildren()) do table.insert(blockers,e) end table.sort() This is of course assuming that the only children of blocker are, (a,b,c,etc.) otherwise you could just stick with what you have now.