|
| 10 Jun 2012 12:35 PM |
I know you are recommended to use a for loop with this, but I want all the children of a gui to turn visible. Here's what I have:
script.Parent.MouseButton1Down:connect(function() local p = spp.CapsContent:GetChildren() local spp = script.Parent.Parent for i = 1,#p do Visible = true end end)
-- This obviously doesn't work out, any help? |
|
|
| Report Abuse |
|
|
|
| 10 Jun 2012 12:37 PM |
script.Parent.MouseButton1Down:connect(function() local p = spp.CapsContent:GetChildren() local spp = script.Parent.Parent for i = 1,#p do p[i].Visible = true end end)
- Striked |
|
|
| Report Abuse |
|
|
|
| 10 Jun 2012 12:48 PM |
Hmm.. doesn't seem to do anything :/ (nothing in output)
Maybe something's wrong with the local stuff?
|
|
|
| Report Abuse |
|
|
129K
|
  |
| Joined: 23 Aug 2011 |
| Total Posts: 19010 |
|
|
| 10 Jun 2012 12:55 PM |
"script.Parent.MouseButton1Down:connect(function() local p = spp.CapsContent:GetChildren() local spp = script.Parent.Parent for i = 1,#p do Visible = true end end)"
script.Parent.MouseButton1Down:connect(function() local p = spp.CapsContent local spp = script.Parent.Parent for _,x in pairs(p:GetChildren()) do Visible = true end end) |
|
|
| Report Abuse |
|
|
|
| 10 Jun 2012 01:12 PM |
| Still doesn't do anything nor say anything in the output :/ |
|
|
| Report Abuse |
|
|
|
| 10 Jun 2012 01:24 PM |
| Shouldn't spp be the first variable? |
|
|
| Report Abuse |
|
|
|
| 10 Jun 2012 01:31 PM |
| Yes, spp should be stated before p. |
|
|
| Report Abuse |
|
|
NXTBoy
|
  |
| Joined: 25 Aug 2008 |
| Total Posts: 4533 |
|
|
| 10 Jun 2012 01:55 PM |
These two lines are in the wrong order:
local p = spp.CapsContent local spp = script.Parent.Parent
The first one reference the second before it is defined!
Having said that, you should change your code to this:
script.Parent.MouseButton1Down:connect(function() local spp = script.Parent.Parent for _, child in ipairs(spp.CapsContent:GetChildren()) do child.Visible = true end end)
`ipairs()` is a better way of looping than using integers. |
|
|
| Report Abuse |
|
|
|
| 10 Jun 2012 02:40 PM |
Nothing's happening >.>
No idea what's wrong.. maybe something to do with the local stuff? |
|
|
| Report Abuse |
|
|