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
|
  |
| Joined: 29 Mar 2009 |
| Total Posts: 3332 |
|
|
| 08 Nov 2016 09:48 AM |
any errors?
you probably need :WaitForChild()'s |
|
|
| Report Abuse |
|
|
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
|
  |
| Joined: 29 Mar 2009 |
| Total Posts: 3332 |
|
| |
|
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
|
  |
| 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 |
|
|