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
 

Problem with Loops and GetChildren()

Previous Thread :: Next Thread 
MastaJames is not online. MastaJames
Joined: 10 May 2009
Total Posts: 237
15 Aug 2012 08:43 AM
I am struggling to find out what this problem is. I've searched it over multiple times but can not fine what is wrong. Output says it is fine but it definitively is not. The script operates, just not correctly.

    local Person = {"MastaJames", "africansoldier"}
    local children1 = script.Parent.Glass:GetChildren()
    function onChatted(msg, recipient, speaker)
    if string.lower(msg) == "open" then
        for i = 1, #Person do
            if speaker.Name == Person[i] then
                for i = 1, #children1 do
                    if children1[i]:IsA("Part") or children[i]:IsA("WedgePart") then
                        for u = 0.5, 1, 0.01 do
                            children1[i].Transparency = u
                            wait(0.1)
                            end
                            children1[i].CanCollide = false
                        end
                    end
                end
            end
        end
    end
    
    function onPlayerEntered(newPlayer)
    newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end)
    end
    
    game.Players.ChildAdded:connect(onPlayerEntered)

When I run this script, the not all of the children in the model Glass disappear. Some go off and some don't. I made sure I had the correct part types and everything. I just don't know what I did wrong...

Please try your best to help me!
Report Abuse
MastaJames is not online. MastaJames
Joined: 10 May 2009
Total Posts: 237
15 Aug 2012 09:00 AM
I have discovered when testing it that the parts I am trying to change the transparency of are changing on at a time for some reason that is over my head. I have no idea what is going on here. Anybody know what could be going on here?
Report Abuse
MastaJames is not online. MastaJames
Joined: 10 May 2009
Total Posts: 237
15 Aug 2012 02:06 PM
Bump
Report Abuse
nickbricknick464 is not online. nickbricknick464
Joined: 22 Aug 2008
Total Posts: 8302
15 Aug 2012 02:21 PM
if children1[i]:IsA("Part") or children[i]:IsA("WedgePart") then

-- You mispelt children1 after the OR

if children1[i]:IsA("Part") or children1[i]:IsA("WedgePart") then
Report Abuse
MastaJames is not online. MastaJames
Joined: 10 May 2009
Total Posts: 237
15 Aug 2012 03:21 PM
I fixed the misspelling, but I still have the same problem. The bricks are not loading correctly. It loads one brick at a time instead of all at once. The problem lies somewhere in here. If you need to, refer to my first post to see the whole script.

for i = 1, #children1 do
if children1[i]:IsA("Part") or children[i]:IsA("WedgePart") then
for u = 0.5, 1, 0.01 do
children1[i].Transparency = u
wait(0.1)

There is sufficient amounts of ends and children1 is equal to script.Parent.Glass:GetChildren(). Glass is the model I want to get the it's bricks to change transparency.

Any idea what is going on here?
Report Abuse
MastaJames is not online. MastaJames
Joined: 10 May 2009
Total Posts: 237
15 Aug 2012 05:06 PM
Bump
Report Abuse
MastaJames is not online. MastaJames
Joined: 10 May 2009
Total Posts: 237
15 Aug 2012 08:26 PM
Bump, I really need help!
Report Abuse
MastaJames is not online. MastaJames
Joined: 10 May 2009
Total Posts: 237
16 Aug 2012 09:57 AM
Bump
Report Abuse
MrChickens is not online. MrChickens
Joined: 21 Feb 2009
Total Posts: 1076
16 Aug 2012 10:02 AM
Just remove the wait(0.1).
Report Abuse
Destroshun is not online. Destroshun
Joined: 12 Aug 2012
Total Posts: 764
16 Aug 2012 10:08 AM
@Mr,
You don't understand, he's trying to make fading type of glass...
Report Abuse
MastaJames is not online. MastaJames
Joined: 10 May 2009
Total Posts: 237
16 Aug 2012 10:24 AM
The glass is going to slowly disappear, yes. The problem with this script is that for some reason It only does one brick at a time. I have yet to find out why this does this. That's why I need your help.
Report Abuse
MastaJames is not online. MastaJames
Joined: 10 May 2009
Total Posts: 237
16 Aug 2012 11:51 AM
Bump
Report Abuse
general75 is not online. general75
Joined: 25 Sep 2008
Total Posts: 21
16 Aug 2012 12:44 PM
On Line 4 -if string.lower(msg) == "open" then- needs to be
if(string.lower(msg1,4)"open") then
Report Abuse
mamaguy is not online. mamaguy
Joined: 07 Oct 2010
Total Posts: 7073
16 Aug 2012 12:51 PM
@General,
Or
if string.sub(msg, 1) == "open" then
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