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 » Scripters
Home Search
 

Re: Nooby question about tables.

Previous Thread :: Next Thread 
Klink45 is not online. Klink45
Joined: 06 Jun 2011
Total Posts: 26054
31 Jul 2015 04:21 PM
How do I get one instance from a table? Right now I am getting a number, but I want the instance. This doesn't work:

local Parent = script.Parent
local Music = Parent.Parent.Parent.Parent.Parent:WaitForChild("Music"):GetChildren()
local AvailableSongs = {}

for _,track in pairs(Music) do
if not track.Taken.Value then
table.insert(AvailableSongs,track)
track.Taken.Value = true
end
end

local chosenPlateNum = math.random(#, AvailableSongs)
local chosenPlate = AvailableSongs[chosenPlateNum]
table.remove(AvailableSongs,chosenPlateNum)
script.Parent.Image = "rbxassetid://"..chosenPlateNum:WaitForChild("Art").Value

u sicko!
Report Abuse
Botchan is not online. Botchan
Joined: 14 Jun 2015
Total Posts: 269
31 Jul 2015 04:22 PM
You cannot save instances in a table. Only values.
Report Abuse
Klink45 is not online. Klink45
Joined: 06 Jun 2011
Total Posts: 26054
31 Jul 2015 04:25 PM
But here my value represents an instance. How can I then tell it to do something with the instance?

u sicko!
Report Abuse
TickerOfTime is not online. TickerOfTime
Joined: 02 Sep 2012
Total Posts: 2030
31 Jul 2015 04:28 PM
Did you perhaps mean this?

local Parent = script.Parent
local Music = Parent.Parent.Parent.Parent.Parent:WaitForChild("Music"):GetChildren()
local AvailableSongs = {}

for _,track in pairs(Music) do
if not track.Taken.Value then
table.insert(AvailableSongs,track)
track.Taken.Value = true
end
end

local chosenPlateNum = math.random(#, AvailableSongs)
local chosenPlate = AvailableSongs[chosenPlateNum]
table.remove(AvailableSongs,chosenPlateNum)
script.Parent.Image = "rbxassetid://"..chosenPlate:WaitForChild("Art").Value
Report Abuse
Klink45 is not online. Klink45
Joined: 06 Jun 2011
Total Posts: 26054
31 Jul 2015 04:28 PM
YES
THANK YOU
But what did I do wrong?

u sicko!
Report Abuse
TickerOfTime is not online. TickerOfTime
Joined: 02 Sep 2012
Total Posts: 2030
01 Aug 2015 08:15 AM
On the scripy.Parent.Image, you had chosenPlateNum. You were calling WaitForChild on an int.

-Ticker of da Tocks | SFBC
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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