Extreme server lag and crashing

So, i’m making a game on ROBLOX and just released an update for it. However, when I go to play on it in play mode, I notice that the “wait for datastore” part of my loading screen always ends up failing (it waits the full alotted time until it teleports the player to my intermission place), but the moment it tries to teleport me to the intermission place, it says that i need to check my internet connection. I go to join back on that same server and get an ID=17 error.

I then go and shutdown the servers and try this multiple times. Still the same result. I then go look at all the game servers and see this:

These are all me, and all these servers were shut down however still displayed. Does anyone have any idea why this is occuring? Someone before has mentioned that it’s likely my code causing it to stall, but I have no idea what is causing it. Does anyone have any ideas as to why this is occuring? I know someone before has mentioned that it can be due to something like a while loop.

(I can’t really send much since I don’t know what script is causing it to crash so badly)

Game Link


First off love the loading UI!

So I joined the game and I got in fine. I used to have an issue similar to this with an admin system. The issue was when you for lack of better words, over join, you can cause the datastore to set multiple saves to your single user. The simple fix is reset the data store by changing its name.
Hopefully this works.


Thank you lol, pretty proud of it.

I don’t think it’s the data store though. It’s the server itself that just “dies” for a lack of a better term. I narrowed the loading screen issue to be with the fact that the server simply doesn’t respond to the client, which in turn could result in that “please check your connection” issue.

This appears to be internal. Also #development-support:scripting-support is for asking assistance on scripts.

Just wait for a while and join again. I do encounter ID=17 errors, but they are not caused by the game.

1 Like

You need to include code responsible for the functions that should happen around the time you notice servers booting you out. Presumably this is wherever your code teleports the player, or retrieves data from the datastore.

I know that. However i’ve got some conflicting sides, one which says that it’s internal and one that says it might be my game scripts. I just decided to post it here since it might be the latter.

The server usually starts booting out as soon as the player joins. Maybe a little later if i’m lucky. Plus there are lots of scripts with lots of code in them that (for the most part) seem to run the moment the server starts (setting up the server environment, connecting to events, etc). How would I go about sending them?

This would certainly help us figure this out. Even if it isn’t the datastore, maybe we can find something while the client/server communicate or when the datastore is called.
The teleportation script would also help as it crashes only when trying to teleport.

Basically you should send the client-side code that handles the UI for loading the datastore, the server-side code that handles the datastore, and the server-side code that teleports the player.

Alright. In terms of the UI it waits for a value to be set (StatsLoaded), and when it does it goes through with the intro. I can send the client side code if you would like but that shouldn’t really affect the server.

In terms of the server, here is the script that handles loading data:

local defaultStats = {100,50, 400}
function LoadStats(plr, stats)
    if(#stats >= 1) then
	    plr.MaxHealth.Value = stats[1]
    if(#stats >= 2) then
	    plr.Bits.Value = stats[2]
    if(#stats >= 3) then
	    plr.ReserveAmmo.Value = stats[3]

function LoadHats(plr, hats, name)
    for i,v in pairs(hats) do
	    Instance.new("ScreenGui", plr:FindFirstChild(name)).Name = v

local loadSuccess, loadErr = pcall(function()
	if(game:GetService("RunService"):IsStudio() == false) then
		local stats = store:GetAsync(plr.UserId)
		local hats = store:GetAsync(plr.UserId.."HATS")
		local hacks = store:GetAsync(plr.UserId.."HACKS")
		if(stats ~= nil) then
			LoadStats(plr, stats)
			game.ReplicatedStorage.RemoteEvents.Chat:FireClient(plr, "Stats loaded succesfully!")
		if(hats ~= nil) then
			LoadHats(plr, hats, "OwnedHats")
			game.ReplicatedStorage.RemoteEvents.Chat:FireClient(plr, "Hats loaded successfully!")
		if(hacks ~= nil) then
			LoadHats(plr, hacks, "OwnedHacks")
			game.ReplicatedStorage.RemoteEvents.Chat:FireClient(plr, "Hacks loaded successfully!")
	plr.StatsLoaded.Value = true
if(loadSuccess == false) then
	game.ReplicatedStorage.RemoteEvents.Chat:FireClient(plr, "Error occured while loading data: "..loadErr, BrickColor.new("Really red").Color)


function Tele(plrs)
    local private = game:GetService("TeleportService"):ReserveServer(3475953004)
    game:GetService("TeleportService"):TeleportToPrivateServer(3475953004, private, plrs)

(Again client side code is nothing apart from waiting for “StatsLoaded” to be true and just firing the function “Tele” connected to the remote event when they don’t successfully load)

Well out of context everything seems to be fine. Are there any other scripts that fire only after the Waiting for Datastore screen?

If not, then perhaps we should look at the client-side code. Perhaps the issue may be in the remote events/functions causing it to somehow crash the server or something?

I don’t think it might be any of these though, since everything remained untouched and worked fine in previous updates. I’m starting to think it maybe might be the server setup script though since i DID add something that runs at runtime. Problem is that it works in studio (even in test mode), just not on the website/team test/whatever.

--Create WIFI hotspots
local hotspots = Instance.new("Folder", game.ServerStorage)
hotspots.Name = "Hotspots"
for i=1, 10 do
local hotspot = Instance.new("Vector3Value", hotspots)
	local function RecursiveInfo()
		local id = math.random(1, 99999999)
		local info = nil
		local success, err = pcall(function()
			info = game:GetService("MarketplaceService"):GetProductInfo(id)
		if(success == false) then
			return RecursiveInfo()
		return info
	hotspot.Name = RecursiveInfo().Name.."|"..math.random(1,10000)
local size = workspace.Baseplate.Size
hotspot.Value = Vector3.new(math.random(-size.X/2,size.X/2), workspace.Baseplate.Position.Y, math.random(-size.Z/2, size.Z/2))

local strength = Instance.new("IntValue", hotspot)
strength.Name = "SignalStrength"
strength.Value = math.random(30, 100)

If this isn’t the culprit then i’m honestly stumped.

What happens when you disable this script/code? Have you tested it on an online Roblox server with this disabled?

I just want to get a good idea of where the problem actually is before going through each line and debugging it only to realize that it isn’t the problem.

Yeah that’s a fair point haha.
Anyway I just tried it with the code commented out but it’s still kicking everyone out.

Well then I guess it isn’t the culprit after all!

Unfortunately, this complicates things…

At this point, I’d load a backup from a version that was 100% previously working to see if it still works. If it does, then you’d know it is something you’ve added/done. If not, then it’s not on your end.

So back to the datastore, I’ve noticed you don’t actually load the data if you’re in studio:

If you remove this and run it in studio, does it create any issues? If it does, consider wiping the datastore as said previously. Once the data is wiped, try the online server again to see if it was corrupted data or something.

Another thing you should look for are any malicious scripts. They can sneak in through models from the library or even plugins. Just scan the game and make sure all of the scripts are yours. (tbh though this is probably not the case as it does seem to wait for your loading screen and I’d think a malicious script would shut it down instantly)

That’s a good point actually. Also, I did load a previous version and it was something I did considering it worked previously.
Anyway I removed my line and the datastore works in studio. As usual. So I don’t think that is the culprit.
Also, yes, I don’t think it’s malicious scripts either for the reason you mentioned, and because I used my plugin and saw no scripts had any weird names or code

The save data part still has the :IsStudio line, but that would just be overkill to remove it considering it doesn’t run anywhere close to the 10 seconds it takes upon joining the game (or maybe before the loading screen entirely)

EDIT: Wow I actually noticed something. When I run in test mode (with a server and a client seperate) the same issue happens, just not with the message box popping up saying “Please check your internet connection” and whatnot. It appears the player is IN the game, but they couldn’t load their character.

So it’s not the datastore. So what the best option from this point is to go over everything you’ve added. Just skim through the scripts. You’re looking for things that might:

  • Overload the server
  • Cause logic conflicts (could possibly result in an error)
  • Include deprecated methods (Most deprecated methods are backwards compatible though)
  • Have a difference between Studio and an Online game
  • Run while the player is loading/teleporting

This is not an ideal solution, but if you find something that you think could be suspicious, then post it here. If you want to narrow down your search, you can try to find the latest backup version that works and then from there only search the new scripts/changes.

Unfortunately this isn’t a great solution, but it’s what I would do.

I think I found the issue (Keyword: think). I ran the test server in Network Simulator mode and without it. I noticed that if the requests DO fail (atleast one) then the server doesn’t work. If it doesn’t fail (that is, if i turn the simulator mode off) then it works well.
How would I do about preventing this however? I’m using pcall for these functions but they’re still vulnerable.

Are you able to pinpoint which one fails? If you can see where it fails, you can dissect it and see what causes it to go fatal.

Other than that, make sure you’re not depending on anything in a request not to fail.

local a = nil
local b = 15
 a = 5 --Pretend this is a request that can fail

c = a+b
print(c) -- this will fail because if the pcall isn't successful, a will still be nil

Make sure you are constantly checking if the pcall returned successful and are not doing anything with an unchecked pcall or it’s variables. When the pcall does return with an error, make sure to print the error.

Network Simulator tells me which one fails. It’s random of course, but in the output it’s a mix between MarketplaceService (handled by the Server Setup code I sent earlier) and Analytics (one which I sadly don’t have much control over)
I checked the code for MarketplaceService and DataStoreService. Marketplace service seems to be alright but I can maybe try putting DataStoreService inside a spawn if that might clog up the main thread

Anything that is a network call should be in a pcall. Otherwise, it will stop that thread’s execution if it fails