Pausing Sound on Server does Pause the Sound for players?
Asked by
4 years ago Edited 4 years ago
I came across this very annoying bug where I am using RemoteEvents to pause, play, stop, and resume sound on the game, which uses an if statement to separate them. The problem is that once it plays the sound, I am unable to pause or stop it once it is playing. I desperately need help on this as this is very important for me game that everyone hears the same music. If you really need the code, I'll post it on here.
Plus, I would want an answer to this as this will make me know more about lua as to do this is something I don't know yet and I am still learn Lua a bit. I know a lot about lua but I am actually still working with RemoteEvents as it seem that this game I am making seems to need them quite a bit. I also learn better when I am doing projects as well.
The game I am making is a DJ type game so that is why a lot of things are labeled with DJ inside.
Module Script ID: 1 = The Module script the script calls, this module script is quite important for future reference in my code so not many bugs are accidentally created if I forgot anything. This is also suppose to act as a sort of template as well so I could use this single line of code for a lot of different things.
Module Name: DJPlayer
01 | function DJPlayer.MediaPlayer(Mode,TimePos,SoundId) |
02 | local Path = game:GetService( "SoundService" ).DJMusic.Music |
03 | if SoundId ~ = nil then |
05 | DJPlayer.PlayerId(SoundId) |
07 | if TimePos ~ = nil then |
09 | Path.TimePosition = TimePos |
12 | if Mode = = "Play" then |
15 | elseif Mode = = "Stop" then |
18 | elseif Mode = = "Resume" then |
21 | elseif Mode = = "Pause" then |
25 | error (Mode .. " is an invalid sound mode" ) |
Script ID: 2 = The script where it detects the serverEvent
1 | local Replicate = game:GetService( "ReplicatedStorage" ) |
2 | local MediaEvent = Replicate:WaitForChild( "MediaPlayer" ) |
3 | local DJPlayer = require(game.ReplicatedStorage.Modules.Game.DJPlayer) |
5 | MediaEvent.OnServerEvent:connect( function (Player,Mode,TimePos,SoundId) |
6 | DJPlayer.MediaPlayer(Mode,TimePos,SoundId) |
LocalScript ID: 3 = The localscript of where the player is using. This is important for whoever the DJ of the game is. I am only going to include parts of what is more important and most other elements I have tested and worked. So only including things that is link to the problem I might have
1 | local MediaEvent = game:GetService( "ReplicatedStorage" ):WaitForChild( "MediaPlayer" ) |
3 | MediaEvent:FireServer( "Stop" ) |
Edit: I still need help with this as to why it happens.
Edit #2: Just to notify, I still need help us this is a problem I am unsure to help with. If you are a bit confused of what I am asking than please don't hesitate to ask what part you are confused about.