I hope that everyone reading this is doing well. Recently, while I’ve been working on my game, there has been a game-killing issue where the client will freeze onJoin. If I am already playing in a server and someone joins, they will shortly leave and rejoin, and when I ask them if they rejoined because their client froze, they always say yes. It has happened to me several times too; I will join a pre-existing server but my client will freeze. It happens both before, during and after the default loading screen fades away. However, the in-game music still plays! In addition, my mouse icon is stuck at 0,0.
If I try to leave the game, my character will still be loaded in as if the server doesn’t realize that I left until like twenty seconds later. If I rejoin while my character is still in, there will be a warning message saying “you’re already playing on another device” or something like that. This bug sounds like a client-sided issue since the server itself isn’t freezing though I have yet to find any localscripts that could cause this issue.
What I’ve tried to do
The map can generate anywhere between 8000 to 20000 parts; however, even when the MapScript is disabled, I’ve still had this issue.
I spent an entire day a week or two ago going through every script and localscript in the game to find any memory leaks. To my knowledge, there aren’t any memory leaks or server-client bridge issues except for one thing… the PlayerAdded event has a memory leak, I believe. since I fixed that problem thanks to:
The only reason why I haven’t marked this thread as solved is because the freezing issue is still a problem that plagues several people at random times.
Any help is appreciated! This is a serious issue, and I would love to move past this as soon as possible. Thanks for reading all of this. Cheers ~ Eko
Problem is that you are creating a new PlayerRemoving connection every time a player joins when what you should do is move that event outside the scope of PlayerAdded event:
game.Players.PlayerAdded:Connect(function(player)
-- A bunch of datastore Getting and Setting
-- A Chat Command Function
end)
game.Players.PlayerRemoving:Connect(function()
print'bye' --checking for memory leak
end)
Alright, I just tested it, and there’s now only one “bye”. Thank you for that! As far as the client freezing, do you think that was the cause or is there something else going on?
No, I haven’t used any plugins besides Roblox’s animation editor. Also, I just tried to go into a server to check out Script Performance, and it crashed before I could even do anything.
As for trying it in Studio, if I publish my game to the website and try to Play Solo, when I exit Play Solo, there’s a good chance that it’ll crash there too. I’m not sure if that’s related or not.
But now that I’m loaded in, these stats don’t look too out of the ordinary. But then again, I could be wrong since this is the first time that I’ve had to really crack down on this. Thanks for the help.
Reason #266 is “The smart card service is not running. Please start the smart card service and try again”. Not sure what any of this means or if it’s related.
To further confirm that it’s not the loading of thousands of parts onJoin, I enabled Streaming and set the radius to 4096. Way outside the radius at a Y level of 8192 studs, players now join the server in a spawn above the map. Once they press the “play” button on the screen, they are teleported to the lobby where the client then has to load all of the parts from the map and lobby. This was an attempt to prevent the client from having to load so many parts onJoin, but it still freezes from onJoin to onJoin. Here’s the game link: Ultimate Brick Battle 💣 - Roblox.
Sooooo I think I discovered the issue. Found this at the end of a LocalScript deep within StarterGui.
local isPlayingSong = false
while true do
for i, song in pairs(script.Songs:GetChildren()) do
if song.Playing == true then
isPlayingSong = true
end
end
if not isPlayingSong then
if #songs == 0 then
songs = {}
for i, song in pairs(script.Songs:GetChildren()) do
if song.Active.Value == true then
table.insert(songs, song)
if song.Name == "Darkest Omen (Chrono Symphonic)" then
table.insert(songs, song["Darkest Omen [Part 2] (Chrono Symphonic)"])
elseif song.Name == "The Masamune (Chrono Symphonic)" then
table.insert(songs, song["The Masamune [Part 2] (Chrono Symphonic)"])
table.insert(songs, song["The Masamune [Part 3] (Chrono Symphonic)"])
end
end
end
end
if lastSong == "Darkest Omen (Chrono Symphonic)" then
PlaySong(script.Songs["Darkest Omen (Chrono Symphonic)"]["Darkest Omen [Part 2] (Chrono Symphonic)"], true)
elseif lastSong == "The Masamune (Chrono Symphonic)" then
PlaySong(script.Songs["The Masamune (Chrono Symphonic)"]["The Masamune [Part 2] (Chrono Symphonic)"], true)
elseif lastSong == "The Masamune [Part 2] (Chrono Symphonic)" then
PlaySong(script.Songs["The Masamune (Chrono Symphonic)"]["The Masamune [Part 3] (Chrono Symphonic)"], true)
else
local newSong
repeat newSong = math.random(1, #songs)
until string.find(songs[newSong].Name, "Part") == nil
PlaySong(newSong, false)
end
end
isPlayingSong = false
end
There’s a wait(2) in the PlaySong() function. I assumed that if I call PlaySong(), I don’t have to add any waits between while loop intervals. I added a wait(0.5) at the end of the loop and never had an issue again. Here’s what’s interesting:
In the bottom right, you can actually see that no song is playing (there’s supposed to be a song playing) which means that if I didn’t include that wait(0.5), I would’ve frozen again. Of course, now the issue is “why isn’t my playlist playing 100% of the time” but that’s something that I can probably figure out a little later. Thanks again to everyone who checked out this thread!