Klink45
|
  |
| Joined: 06 Jun 2011 |
| Total Posts: 26054 |
|
|
| 31 Jul 2015 03:37 PM |
I'm trying to make images of a randomly selected song for my game, but the issue is I don't want the same song to show up twice. So I tried writing this
--[[ Lot's of parents ahead. --]] 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
But on line 8 it errors. I thought music was an instance though?
u sicko! |
|
|
| Report Abuse |
|
|
Ukrainest
|
  |
| Joined: 31 May 2015 |
| Total Posts: 324 |
|
|
| 31 Jul 2015 03:38 PM |
| idk if music's an instance, i know sound is |
|
|
| Report Abuse |
|
|
Klink45
|
  |
| Joined: 06 Jun 2011 |
| Total Posts: 26054 |
|
|
| 31 Jul 2015 03:38 PM |
Music is a folder's children.
u sicko! |
|
|
| Report Abuse |
|
|
| |
|
Klink45
|
  |
| Joined: 06 Jun 2011 |
| Total Posts: 26054 |
|
|
| 31 Jul 2015 03:52 PM |
I think I did something weird with the table that I don't see because after doing this: --[[ Lot's of parents ahead. --]] 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
On the very last line it says "attempt to index local 'chosenPlateNum' (a number value)"
u sicko! |
|
|
| Report Abuse |
|
|
Klink45
|
  |
| Joined: 06 Jun 2011 |
| Total Posts: 26054 |
|
| |
|
Klink45
|
  |
| Joined: 06 Jun 2011 |
| Total Posts: 26054 |
|
| |
|
|
| 31 Jul 2015 04:25 PM |
Lol Try to change the local 'Parent' to something else like pparent or something, maybe it's clashing with the actual 'Parent's
If money grew on trees... It would be as valuable as leaves. | Twitter: @TwisterRBLX |
|
|
| Report Abuse |
|
|
Klink45
|
  |
| Joined: 06 Jun 2011 |
| Total Posts: 26054 |
|
| |
|