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: Why does this only work in studio but not in game?

Previous Thread :: Next Thread 
kings53 is not online. kings53
Joined: 17 Jul 2012
Total Posts: 4375
08 Nov 2016 09:47 AM
Hi,

I have a sound system in my game where music is played through a Sound instance inserted into each Player upon joining, so the music can be toggled by the player at will. The system works fine in studio, however in game no music is played whatsoever. What's going on? I can provide necessary snippets of the code if needed.

Thanks,

kings53


Report Abuse
HlCOM is not online. HlCOM
Joined: 29 Mar 2009
Total Posts: 3332
08 Nov 2016 09:48 AM
any errors?

you probably need :WaitForChild()'s
Report Abuse
kings53 is not online. kings53
Joined: 17 Jul 2012
Total Posts: 4375
08 Nov 2016 09:51 AM
hlcom,

all necessary waitforchilds are implemented. the output shows no errors for the script.


Report Abuse
HlCOM is not online. HlCOM
Joined: 29 Mar 2009
Total Posts: 3332
08 Nov 2016 09:56 AM
post full script
Report Abuse
kings53 is not online. kings53
Joined: 17 Jul 2012
Total Posts: 4375
08 Nov 2016 10:01 AM
this is the portion of code in the main script that controls music playing:


function queueSong(song, player) --syntax: Soundtable song, String player
if player == "all" then
for i,v in pairs(game.Players:GetPlayers()) do
v:WaitForChild("ActiveSound"):Stop()
v.ActiveSound.SoundId = song[3].SoundId
end
else
local plrPlayer = game.Players:FindFirstChild(player)
if plrPlayer == nil then return false end
plrPlayer:WaitForChild("ActiveSound"):Stop()
plrPlayer.ActiveSound.SoundId = song[3].SoundId
end
end

function playSong(player)
wait(0.5)
if player == "all" then
for i,v in pairs(game.Players:GetPlayers()) do
v:WaitForChild("ActiveSound"):Play()
end
else
local player2 = game.Players:FindFirstChild(player)
if player2 == nil then return false end
wait(0.5)
player2:WaitForChild("ActiveSound"):Play()
end
end

function stopSong(player)
if player == "all" then
for i,v in pairs(game.Players:GetPlayers()) do
v:WaitForChild("ActiveSound"):Stop()
end
else
local player2 = game.Players:FindFirstChild(player)
if player2 == nil then return false end
wait(0.5)
player2:WaitForChild("ActiveSound"):Stop()
end
end


game.Players.PlayerAdded:connect(function(player)
local sound = Instance.new("Sound", player)
sound.Name = "ActiveSound"
sound.Volume = 1
sound.Looped = true
queueSong(selectedSong, player.Name)
playSong(player.Name)
end)

function isLobbySongPlaying() -- Due to my codeveloper's amazing coding skills and methods, this function had to be created in order for the music toggle feature to work.
for i,v in pairs(lobbyMusicIDs) do
if v == song3.Value then
return true
end
end
return false
end

a sound table works like this: {String songname,String songartist, Sound soundpointer)

throughout the game, calls are made to queueSong() when song changes need to be made though the music never plays in the actual game

the toggle code shouldn't be necessary, as it's always enabled by default (meaning music will always play when you first join)


Report Abuse
HlCOM is not online. HlCOM
Joined: 29 Mar 2009
Total Posts: 3332
08 Nov 2016 10:05 AM
i was not expecting that

uh

add print statements everywhere and see where it breaks
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