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 » Game Design
Home Search
 

Re: Play() error?

Previous Thread :: Next Thread 
jjwood1600 is online. jjwood1600
Joined: 14 May 2013
Total Posts: 1633
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
championbuilder is not online. championbuilder
Joined: 20 Jan 2009
Total Posts: 13544
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
championbuilder is not online. championbuilder
Joined: 20 Jan 2009
Total Posts: 13544
17 Aug 2015 02:20 PM
unless the audio are numbers... GOD DAMN IT. I don't know.
Report Abuse
jjwood1600 is online. jjwood1600
Joined: 14 May 2013
Total Posts: 1633
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
championbuilder is not online. championbuilder
Joined: 20 Jan 2009
Total Posts: 13544
17 Aug 2015 02:24 PM
does gamesong just have audio in, or is there anything else?
Report Abuse
jjwood1600 is online. jjwood1600
Joined: 14 May 2013
Total Posts: 1633
17 Aug 2015 02:25 PM
Just audio.
Report Abuse
championbuilder is not online. championbuilder
Joined: 20 Jan 2009
Total Posts: 13544
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
jjwood1600 is online. jjwood1600
Joined: 14 May 2013
Total Posts: 1633
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
BluesteelBoyz is not online. BluesteelBoyz
Joined: 15 Feb 2012
Total Posts: 1841
17 Aug 2015 02:32 PM
yes.

http://web.roblox.com/games/281290108/Blocky-Dudes-BD-SHOP
Report Abuse
jjwood1600 is online. jjwood1600
Joined: 14 May 2013
Total Posts: 1633
17 Aug 2015 02:36 PM
So, Any ideas? :(
Report Abuse
championbuilder is not online. championbuilder
Joined: 20 Jan 2009
Total Posts: 13544
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
jjwood1600 is online. jjwood1600
Joined: 14 May 2013
Total Posts: 1633
17 Aug 2015 02:38 PM
The names are not numbers :(
Report Abuse
championbuilder is not online. championbuilder
Joined: 20 Jan 2009
Total Posts: 13544
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
jjwood1600 is online. jjwood1600
Joined: 14 May 2013
Total Posts: 1633
17 Aug 2015 03:03 PM
Thanks!
It seems to be working! :D
Report Abuse
bowlingmaster87 is not online. bowlingmaster87
Joined: 11 Sep 2015
Total Posts: 1
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
KorbloxGeneral214 is not online. KorbloxGeneral214
Joined: 05 May 2014
Total Posts: 254
01 Feb 2017 10:43 PM
Only me works.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Game Design
   
 
   
  • 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