generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: :GetChildren()

Previous Thread :: Next Thread 
UberPlayer is not online. UberPlayer
Joined: 24 Jul 2010
Total Posts: 722
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
LordStriked is not online. LordStriked
Joined: 19 Mar 2011
Total Posts: 5396
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
UberPlayer is not online. UberPlayer
Joined: 24 Jul 2010
Total Posts: 722
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 is not online. 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
UberPlayer is not online. UberPlayer
Joined: 24 Jul 2010
Total Posts: 722
10 Jun 2012 01:12 PM
Still doesn't do anything nor say anything in the output :/
Report Abuse
zapzing303 is not online. zapzing303
Joined: 05 Mar 2010
Total Posts: 1486
10 Jun 2012 01:24 PM
Shouldn't spp be the first variable?
Report Abuse
ServerLabs is not online. ServerLabs
Joined: 29 Dec 2010
Total Posts: 2263
10 Jun 2012 01:31 PM
Yes, spp should be stated before p.
Report Abuse
NXTBoy is not online. 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
UberPlayer is not online. UberPlayer
Joined: 24 Jul 2010
Total Posts: 722
10 Jun 2012 02:40 PM
Nothing's happening >.>

No idea what's wrong.. maybe something to do with the local stuff?
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image