How does one reduce ping in their game?

Im very confused with this. Why does my game have higher ping than the other games? For example, ill show you the ping in certain games.

Robeats
image

Arsenal
image

literally an empty baseplate
image

Now, the first 2 games do get high ping when you first join the game, but it quickly dies down to 2 digits after 10 seconds. I wonder if they have some sort of code that takes care of ping. If so, how do they achieve that? I really need answers because my game can become very janky with high ping.

I have only a thing: Don’t use Debris. Rare, Debris will not destroy the part in that seconds or even not destroy it. Please, don’t use Debris

1 Like

You checked the Search bar? There are over 100 posts about why Debris is bad.

There is a post:

You could just write your own function instead - Destroy() is guaranteed to work and GC any connections that object has, and with your own function you can extend it to handle different objects in different ways. Say, for example, you want a Light object to fade out before being destroyed. Throw in a couple of type checks too if you’re like me and accidentally try to put null values in Instance-shaped holes.

function GCObject(obj,gcWait)
	if typeof(obj) == "Instance" and typeof(gcWait) == "number" then
		if obj:IsA("Light") then
			local tweenInfo = TweenInfo.new(gcWait,Enum.EasingStyle.Linear)
			local tween game:GetService("TweenService"):Create(obj,tweenInfo,{Brightness = 0})
			tween:Play()
		end
		
		wait(gcWait)
		obj:Destroy()
	else
		warn("Passed arguments were not Instance,Number")
	end
end

Tuck this function away in a ModuleScript and you’re laughing, just call the function with the exact same arguments as AddItem. More extensible, guaranteed to work, and it’s just one line to call it.

As for Debris not always working, I can attest to that. The ancient spaghetti monsters that are my raycasted weapons were originally based off the WIJ W2 scripts, which used Debris to clean up the lasers. Often some lasers would be stuck around indefinitely, and I’m not sure it ever got fixed.

To answer your question (sorry, I got off track), ping is simply the time it takes for the server to respond to a query. This can be affected by connection quality, the size of the place, and how much server resources are being taken up by scripts. In short: Optimise, optimise, optimise. Remove parts and scripts you don’t need; the less work the server has to do, the better.

The only thing that’s boggling my mind is that how can a game, which is straight up just an empty baseplate, nothing added whatsoever, have higher ping than the 2 games i mentioned above?

It might also depend on the server - when you start a new server on a game, you never quite know where it’s going to be hosted. I think Roblox uses AWS nowadays, so it’s even more up in the air than “somewhere in the US”.

So in other words, the closer the server is to where i am, the better the connection? Is this why id usually bump in to people who happen to be in the same country as me? I’d also like to know if i can do anything about this.

1 Like

Just dropping in to say that Debris has absolutely nothing to do with ping.

Ping is (simplistically speaking) the time taken for a message to travel from your computer to the Roblox game server in a data centre somewhere, and for that message to return. So, for the most part, there’s not much you can do about it. It’ll vary depending on network connection quality, location of your computer and the game server, and plenty of other factors that you can’t control. You should instead focus on compensating for the network latency, for example by running player actions such as vehicle control and movement locally.

6 Likes

Bingo. As far as I know there’s not really anything you can do about where servers are hosted, but as a general rule Roblox tries to connect you to one hosted as close to you as possible. There are other factors, such as whether or not friends are in that game, and if you manually selected a server, but I don’t know enough about the whole thing beyond that to even really speculate.

1 Like

Sorry for replying to an old topic, its the distance between the roblox servers and the roblox server quality. I have 6ms ping/latency and 5g internet with like 300 mega bits/second and I still get 200 ping. Maybe because I am far away from the roblox servers? Or maybe because the roblox servers are just not very quality.