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 » Scripting Helpers
Home Search
 

Re: How to add sound to a game?

Previous Thread :: Next Thread 
austin19199 is not online. austin19199
Joined: 24 Jan 2009
Total Posts: 224
22 Jun 2013 09:24 PM
Alright, so I have an RPG game and I want to add music to it. Like, how do I do this? I have tried to put the music in the Workspace and then put a Script in the music say "Script.Parent:play()" It did not work in online, only in test. So I tried this "game.Workspace.Music:play()". The sound is called music. Anyways, same thing happened there. Is ther ea way to put music in a game? Like some Rpg games.
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
22 Jun 2013 09:29 PM
Do you have the correct SoundID set? And if so, is the code inside a LocalScript?
Report Abuse
austin19199 is not online. austin19199
Joined: 24 Jan 2009
Total Posts: 224
22 Jun 2013 09:35 PM
Yes, and Yes. But it only works in Test Mode. as in "Tools-Test-Play Solo".
Report Abuse
Epicperson422 is not online. Epicperson422
Joined: 17 Jun 2013
Total Posts: 35
22 Jun 2013 09:43 PM
-- Add a checking statement.

wait(1)
if script.Parent.IsPlaying == false then
script.Parent:play()
else then
repeat()
end
Report Abuse
Epicperson422 is not online. Epicperson422
Joined: 17 Jun 2013
Total Posts: 35
22 Jun 2013 09:44 PM
-- As you may know, I am new to RBX.Lua...I don't know if it should be repeat() or repeat, although it might be repeat
Report Abuse
cooldude999921 is not online. cooldude999921
Joined: 13 Aug 2011
Total Posts: 3702
22 Jun 2013 09:51 PM
    local debounce = false
    function Play(newPlayer)
    if debounce == false then
    debounce = true
    script.Parent.MUSICNAMEHERE:Play().Parent = newPlayer
    repeat wait() until
    music.IsPlaying = false
    end
  end
end

game.Players.ChildAdded:connect(Play)

Must be in a model

game>
    Workspace>
           model>
              Music(Sound)
              script
              

Model must contain the script and Music in one model
Report Abuse
cooldude999921 is not online. cooldude999921
Joined: 13 Aug 2011
Total Posts: 3702
22 Jun 2013 09:52 PM
I might have added an extra end or may be missing one. Please check
Report Abuse
cooldude999921 is not online. cooldude999921
Joined: 13 Aug 2011
Total Posts: 3702
22 Jun 2013 09:54 PM
@zk, Local scripts are mainly for Guis and self running scripts. Nothing to do with sound playing.
Report Abuse
tigerr666 is not online. tigerr666
Joined: 13 Aug 2009
Total Posts: 1665
22 Jun 2013 09:59 PM
@Epic, I recently learned coroutines for lua, and repeat has no "()" after it. :)
Example:
coroutine.resume(coroutine.create(function()
repeat
game.Workspace.bla:destroy()
until
game.Workspace.bla == nil
end))
Report Abuse
Zkiller11 is not online. Zkiller11
Joined: 25 Aug 2009
Total Posts: 2914
22 Jun 2013 10:01 PM
@Cooldude:

Yea, I know that. It's just usually if a script doesn't work online but on test it's because it needs to be a LocalScript (in my own experience).
Report Abuse
cooldude999921 is not online. cooldude999921
Joined: 13 Aug 2011
Total Posts: 3702
22 Jun 2013 10:02 PM
coroutine.create(function(remove)
roblox.Forum.Scripting_Helpers.How_to_add_sound_to_a_game?.AbovePost:Destroy
end)

print(coroutine.Status(remove))

 
Report Abuse
cooldude999921 is not online. cooldude999921
Joined: 13 Aug 2011
Total Posts: 3702
22 Jun 2013 10:03 PM
Lel mines was for the coroutine learner not you xD
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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