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: Sound working in Solo, but not in Server

Previous Thread :: Next Thread 
Happywalker is not online. Happywalker
Joined: 05 Mar 2010
Total Posts: 3672
27 Feb 2015 12:06 PM
function PlaySound()
ChosenSoundId = SoundIds[math.random(1,#SoundIds)]
if ChosenSoundId ~= LastChosenSoundId then
LastChosenSoundId = ChosenSoundId
Sound.SoundId = "http://www.roblox.com/asset/?id="..ChosenSoundId
Sound:Play()
wait(Sound.TimeLength)
Sound:Stop()
PlaySound()
else PlaySound()
end
end

Sound is the Sound Instance in workspace.
SoundIds is a table enholding all Ids, why doesn't it work?
It does not output anything and works fine in Solo.
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
27 Feb 2015 12:12 PM
Idk the problem, but this is easier to type and maybe more efficient. Also, use local variables.

local LastChosenSoundId
function PlaySound()
local ChosenSoundId = SoundIds[math.random(1,#SoundIds)]
if ChosenSoundId ~= LastChosenSoundId then
LastChosenSoundId = ChosenSoundId
Sound.SoundId = "http://www.roblox.com/asset/?id="..ChosenSoundId
Sound:Play()
wait(Sound.TimeLength)
Sound:Stop()
end
PlaySound()
end


Use basic debugging stuff. Try printing TimeLength in online play, see if that works. Also, make sure you give time for the sound to load in Online play, because the assets DO take time to load.
Report Abuse
Happywalker is not online. Happywalker
Joined: 05 Mar 2010
Total Posts: 3672
27 Feb 2015 12:48 PM
Am already preloading it, owing to my console it seems it loops the function, I added some prints and my console gets spammed quickly.

Report Abuse
Happywalker is not online. Happywalker
Joined: 05 Mar 2010
Total Posts: 3672
27 Feb 2015 12:51 PM
Printing TimeLength prints zero all the time ;_;
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
27 Feb 2015 12:54 PM
If it is going over and over too fast, check what I told you about the SoundLength. It apparently doesn't work online, as I thought.
Report Abuse
Happywalker is not online. Happywalker
Joined: 05 Mar 2010
Total Posts: 3672
27 Feb 2015 12:56 PM
I done what you said, and it printed "0".

Well how will I then detect if it stopped? Dx
Report Abuse
Happywalker is not online. Happywalker
Joined: 05 Mar 2010
Total Posts: 3672
27 Feb 2015 01:15 PM
Just added a wait(120) in between,
the best option I think.
Report Abuse
Happywalker is not online. Happywalker
Joined: 05 Mar 2010
Total Posts: 3672
27 Feb 2015 01:19 PM
Played one sound, then stopped doing things.
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