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: attempt to call local 'Music' (a table value)

Previous Thread :: Next Thread 
Klink45 is not online. 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 is not online. 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 is not online. Klink45
Joined: 06 Jun 2011
Total Posts: 26054
31 Jul 2015 03:38 PM
Music is a folder's children.

u sicko!
Report Abuse
Darkmist101 is not online. Darkmist101
Joined: 30 Jul 2010
Total Posts: 6208
31 Jul 2015 03:47 PM
"Music()"
Report Abuse
Klink45 is not online. 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 is not online. Klink45
Joined: 06 Jun 2011
Total Posts: 26054
31 Jul 2015 04:05 PM
qq Really?

u sicko!
Report Abuse
Klink45 is not online. Klink45
Joined: 06 Jun 2011
Total Posts: 26054
31 Jul 2015 04:18 PM
I can't fix it.

u sicko!
Report Abuse
twister1976 is not online. twister1976
Joined: 17 Sep 2010
Total Posts: 2250
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 is not online. Klink45
Joined: 06 Jun 2011
Total Posts: 26054
31 Jul 2015 04:28 PM
Same error.

u sicko!
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