I built blockers for a security checkpoint, but I dont know how to make the script more efficient. I want to do something like this. \/ This is what I came up with, but it does not work. Could I have help?
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} --when this button is clicked, the blocking bricks change to 0 transparency and non-collide function onClicked() blockers.Transparency = 0 blockers.CanCollide = true end script.Parent.ClickDetector.MouseClick:connect(onClicked)
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} --when this button is clicked, the blocking bricks change to 0 transparency and non-collide 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!