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