|
| 17 Aug 2015 02:15 PM |
Hi guys!
function playgamesong() local gamesong = game.Workspace.GameMusic:GetChildren() randomgamesong = gamesong[math.random(1,#gamesong)] randomgamesong:Play() end
This function usually works, when I run it, but randomly it says "Play() is not a valid member of playgamesong()"
Any ideas? Thanks |
|
|
| Report Abuse |
|
|
|
| 17 Aug 2015 02:18 PM |
you're checking if a number between 1 and how many children are in gamesong, are in gamesong.
function playgamesong() local gamesong = game.Workspace.GameMusic:GetChildren() randomgamesong = math.random(1,#gamesong) randomgamesong:Play() end
you were doing
gamesong[math.random(1,#gamesong)], where it finds a number inside the children, instead of getting a number by itself. |
|
|
| Report Abuse |
|
|
|
| 17 Aug 2015 02:20 PM |
| unless the audio are numbers... GOD DAMN IT. I don't know. |
|
|
| Report Abuse |
|
|
|
| 17 Aug 2015 02:22 PM |
I get this error :( Workspace.Main Game Script:601: attempt to index global 'randomsong' (a number value)
Hmm - The first version works fine expect it randomly errors :/ |
|
|
| Report Abuse |
|
|
|
| 17 Aug 2015 02:24 PM |
| does gamesong just have audio in, or is there anything else? |
|
|
| Report Abuse |
|
|
| |
|
|
| 17 Aug 2015 02:26 PM |
try
function playgamesong() local gamesong = game.Workspace.GameMusic:GetChildren() randomgamesong = game.Workspace.GameMusic[math.random(1,#gamesong)] randomgamesong:Play() end |
|
|
| Report Abuse |
|
|
|
| 17 Aug 2015 02:29 PM |
3 is not a valid member of IntValue Script 'Workspace.Main Game Script', Line 601 - global playgamesong
(The songs are stored in an IntValue)
|
|
|
| Report Abuse |
|
|
|
| 17 Aug 2015 02:32 PM |
yes.
http://web.roblox.com/games/281290108/Blocky-Dudes-BD-SHOP |
|
|
| Report Abuse |
|
|
| |
|
|
| 17 Aug 2015 02:38 PM |
| If the names have numbers from 1 to how many there are, I now exactly what to do. If not, I know what to do, but Idk how to do it in Lua. |
|
|
| Report Abuse |
|
|
|
| 17 Aug 2015 02:38 PM |
The names are not numbers :(
|
|
|
| Report Abuse |
|
|
|
| 17 Aug 2015 02:42 PM |
try this, idk.
function playgamesong() local gamesong = gam.Workspace.GameMusic:GetChildren() count = math.random(1,#gamesong) s = 0 for _,v in pairs(gamesong) do s = s + 1 if s == count then v:Play() end end end |
|
|
| Report Abuse |
|
|
|
| 17 Aug 2015 03:03 PM |
Thanks! It seems to be working! :D |
|
|
| Report Abuse |
|
|
|
| 22 Sep 2015 06:16 PM |
| wow this is pretty sad and you know its just that he wont be building or making new and amazing games any more bye bye to you man I will never forget you and all of your amazing games! ): |
|
|
| Report Abuse |
|
|
| |
|