Not sure what to do about this. I have recently made my scripts into modules to get rid of clutter within the main server script. However I’ve come across an issue that literally makes no sense.
MusicHelp:FadeInGameMusic() --module's function being called
function MusicHelp:FadeInGameMusic()
coroutine.wrap(function()
for _,player in pairs (game.Players:GetPlayers()) do
coroutine.wrap(function()
if player.Team~=game.Teams.Lobby then
player.PlayerGui:WaitForChild("MusicFolder")
local Music1=player.PlayerGui.MusicFolder:WaitForChild("Music1")
-- local Music2=player.PlayerGui.MusicFolder:WaitForChild("Music2")
local LobbyMusic=player.PlayerGui.MusicFolder.LobbyMusic
LobbyMusic:Stop()
print(_G.Swampland)
print(player.Team)
if _G.Swampland==1 then --swamp map
print("34")
Music1.Volume=0
--Music1.Volume=0.25
--Music1.TimePosition=.1
Music1:Play()
print(Music1.IsPlaying) --this outputs true
print(Music1.Playing) --this outputs true
--Music2:Play() --tried another sound source
--LobbyMusic:Play()
repeat
Music1.Volume+=.025
wait(.1)
until Music1.Volume>=.675 --.7
end
print(2)
end
end)()
end
end)()
end
It goes through the entire thing, prints everything, I even see that the volume changes and ends at .7 in the actual sound, but for some reason its not playing at all, despite the isplaying and playing both output == true (they are not true when I look at the actual source). I don’t understand what is up. I also tried to play lobby music, which does play when called here. I don’t know what do–any suggestions?
Music that you are playing is located in Players folder which isn’t workspace.
local Music1=player.PlayerGui.MusicFolder:WaitForChild("Music1")
I recomend moving it to player’s character so it will play.
Lobby music must be played locally so it worked because it was fired from local script.
Lobby music is played via server scripts (detects player onadded), I also don’t want to move it to player character because I’m under the assumption that it will play globally in workspace which is definitely something I do not want (My objective is to play sound only to the player and unlike playlocalsound, allow me to control the sound at any time).
I went through to fire a remote to a local script and it still didn’t work.
have you ever put your in-game volume to 0 or mute? I encountered a problem where the music claimed it was playing, and it absolutely stumped me, what I didn’t realize was my volume was 0 and studio is quite quirky with the audio.
I have but, I have other sounds playing so If they don’t play then I know for sure my sound is muted.
PlayGameMusic.OnClientEvent:Connect(function(player, CustomName)
--coroutine.wrap(function()
local MusicFolder=script.Parent:WaitForChild("MusicFolder")
local Music1=MusicFolder:WaitForChild("Music1")
-- local Music2=player.PlayerGui.MusicFolder:WaitForChild("Music2")
local LobbyMusic=MusicFolder.LobbyMusic
LobbyMusic:Stop()
if CustomName == "RETRO: The Swampland" then --swamp map
print("34")
Music1.Volume=.7
Music1:Play()
print(Music1.IsPlaying)
print(Music1.Playing)
--repeat
-- Music1.Volume+=.025
-- wait(.1)
--until Music1.Volume>=.675
end
print(2)
--end)()
end)
Okay well I got it to work, just under a different method (using the onadded event thing I mentioned earlier)
I dislike the method because of the way I have to obtain it, player:loadcharacter may sometimes flash red (like you took damage) which is really stupid and ugly for what I’m trying to execute.
Still doesn’t make sense why the following works and not the one I had in module/main script:
game:GetService('Players').PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
repeat wait() until player:HasAppearanceLoaded()
local LobbyMusic=player.PlayerGui.MusicFolder:WaitForChild("LobbyMusic")
local Music1=player.PlayerGui.MusicFolder:WaitForChild("Music1")
if player.Team==LobbyTeam then
local y=LobbyMusicIDs[math.random(#LobbyMusicIDs)]
if y==blablabla then
LobbyMusic.Volume=.5
end
if y==albalbalb then
LobbyMusic.Volume=.2
end
LobbyMusic.SoundId=string.format("rbxassetid://%d", y)
-- print(LobbyMusic.SoundId)
Music1:Stop()
LobbyMusic:Play()
-- print(3)
end
if player.Team~=LobbyTeam then
LobbyMusic:Stop()
if _G.Swampland==1 then --swamp map
print("34")
Music1.Volume=0
Music1:Play()
print(Music1.IsPlaying)
print(Music1.Playing)
repeat
Music1.Volume+=.025
wait(.1)
until Music1.Volume>=.675
end
end
end)
end)
makes no sense… I’m gonna have to figure out a way to disable the flash of red–ridiculous but just the way I have to do it ig