Suggestions on how to fix common exploits?

My game is in very early stages and for that reason it is paid access. We’re on a free weekend this weekend, and already people on V3rmillion are dropping exploits regarding ammunition count and rate of fire.

Ammunition count is an easy fix, I just need to store the ammo for the weapon on the server;
Rate of fire is not as simple. How do I patch rate of fire exploits without screwing over people with bad ping, or messing up things like burst rifles?

2 Likes

Anti fly script (Read what I say and the two forum posts I link.)

Please look things up on the forum before making a post, especially about topics that are extremely common and thoroughly explained.

You could do some registry on the server so if the client is trying to fire faster than the weapon can, it ignores that signal.

2 Likes

The most logical way to fix fire rate is using the leaky bucket algorithm:

There is a bit more explanation of the algorithm further down in the thread, but this would be the gist of how you handle a ton of requests while allowing wiggle room for high ping players.

2 Likes

Was literally coming back to this post because I assumed OP wasn’t able to find it by looking it up. Thanks anyways, and OP I wouldn’t kick players or do anything like that. I’d simply deny their shots the damage or if they’re ping exceeds a threshold.

1 Like

Yeah, I read your posts on that on your linked threads; Solid solution. Thank you guys!

This is rough progress on a leak bucket; I add 1 to the FireWeapon dataset every time the player fires. BulletsPerShot is what accounts for burst rifles despite rate of fire. Look good?

Edit:
Time between shots is calculated
1/(RateOfFire/60)

so a rate of fire of 300 == 5 shots per second, or .2 second delay

spawn(function()
		while wait(1) do
			for userid, cache in next, clientdata.LeakBucket do
				if clientdata.Cache[userid].EquippedWeapon then
					local weaponData = require(game.ReplicatedStorage.Weapons:FindFirstChild(clientdata.Cache[userid].EquippedWeapon).Information)
					if weaponData.BulletsPerShot then
						local shotsPerSecond = 1/(1/(weaponData.RateOfFire/60)) * weaponData.BulletsPerShot
						clientdata.LeakBucket[userid].FireWeapon = math.clamp(clientdata.LeakBucket[userid].FireWeapon - shotsPerSecond, 0, 1000)
						if clientdata.LeakBucket[userid].FireWeapon > 1.2 * shotsPerSecond then
							clientdata.Cache[userid].Flagged = true
							--// Flag player
						else
							clientdata.Cache[userid].Flagged = false
						end
					end
				end
			end
		end
	end)

This may not work but I believe you can simulate lag with a vpn and connecting to different countries through it. This should hopefully push you to 100-200+ ping.

I’m already 200 ping on any roblox game lol