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: Tables

Previous Thread :: Next Thread 
xvgigakid is not online. xvgigakid
Joined: 22 Jun 2008
Total Posts: 4407
05 Nov 2011 08:03 PM
The script is suppose to give a series of hats to the corresponding player. For example
players[1] will get all the hats in HatID[1]

Output: Players.xvgigakid.Backpack.Script:24: attempt to get length of field '?' (a nil value)



    HatID = {
    player1 = {65075702,65075763,65075809},
    player2 = {123,456,789},
    }
    
    
    players = {"xvgigakid", "bob"}
    
    wait(0.1337)
    num = 0
    
    player = script.Parent.Parent
    print("a")
    for i = 1, #players do
    print("a")
    if player.Name == players[i] then
    print("a")
    num = i
    end
    end
    
    if num ~= 0 then
    for x = 1, #HatID[num] do --LINE24--LINE24--LINE24--LINE24--LINE24--LINE24
    stuff = player.Character:GetChildren()
    for z = 1, #stuff do
    if stuff[i]:IsA("Hat") then
    stuff[i]:remove()
    end
    end
    hat = game:service("InsertService"):LoadAsset(HatID[x])
    end
    end

Report Abuse
Cachinnation is not online. Cachinnation
Joined: 21 Aug 2011
Total Posts: 1797
05 Nov 2011 08:10 PM
num = i

to

num = players[i]

try that
Report Abuse
RATEXmegaGAMER is not online. RATEXmegaGAMER
Joined: 10 Dec 2010
Total Posts: 4046
05 Nov 2011 08:13 PM
@Cachi I'm sure that will make the number an object value.
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
05 Nov 2011 08:32 PM
Your HatID table does not have numerical indices, which is what the # operator gets, so technically it's reading the length of your table as 0.
Report Abuse
xvgigakid is not online. xvgigakid
Joined: 22 Jun 2008
Total Posts: 4407
05 Nov 2011 08:36 PM
@King

I see :/
I never was good at tables. Im guessing the soloution to this has something to do with MetaTables.

So king how do I fix it?
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
05 Nov 2011 08:39 PM
HatID = {
{65075702,65075763,65075809},
{123,456,789},
}
Report Abuse
xvgigakid is not online. xvgigakid
Joined: 22 Jun 2008
Total Posts: 4407
05 Nov 2011 08:40 PM
Really? Is that all?
Lol that wasn't so hard :/
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