So, in my project, I’ve been implementing an anti-exploit, and decided to test it on my phone and my laptop. On the laptop, it runs perfectly fine, but on my phone, it keeps erroneously spotting me for being too speedy. The walkspeed in the game is always at 16, but even when I edit the maximum speed in the anti-exploit up to 25, it still detects the phone for being speedy.
I was curious on how that was to be, so I decided to test with an alt on my phone, and my regular account on my laptop at the same time. I noticed that on the phone, the player seemed to be moving and interacting with the place smoothly, but on the laptop, it kept looking like the device was laggy. My alt’s movements didn’t look as smooth on the computer. There are also other occurrences where it seems like the server notices the player’s movements on the phone more slowly than on the computer. This leads me to prompt my main question(s).
Why is this happening, and how would I reduce lag for mobile players?
Unfortunately, depending on your device’s specs, lag could be unavoidable. Instead of trying to figure out why your phone is lagging, I would try to figure out why your anti-exploit was picking up on the phone but not the computer. Your game is bound to be played by other mobile users with laggy connections, so your game should be prepared to handle them.
Now, I think I know what your problem is. If the sample time for your anti-exploit script is too low, a sudden delay of packets could cause two packets indicating two distant positions to come to the server right next to each other in time, making the player appear to be moving much faster than they actually are. To fix this, you should try increasing the time that the anti-exploit script waits before calculating speed. Try experimenting with different values, like 2 seconds for example. Unfortunately, this means that a speed-hacking player could run in a circle and not be detected, but as long as they aren’t traveling lots of distance, it shouldn’t be that big of a concern gameplay-wise in most cases.
Reducing lag for mobile
Reducing lag is a very open ended topic and it is generally game specific. Could you please provide some more information about your game as this will help us determine what is causing lag in your game. However I can give a very generic answer to reducing lag for mobile:
Check if there is very ‘taxing’ or unnecessary loops in your code. If you have loops for moving gui object, parts ect then you should consider using TweenService instead.
Having lots of badly optimised unions or meches could create more lag.
Do you have any free models in your game as lots of free models are badly optimised and sometimes contain miscellaneous scripts.
Do you have lots of texture and decals everywhere as these could cause a lot of lag. Small amounts of them don’t cause much of a problem but huge amount do.
This isn’t my area of expertise so I am sorry for the limited information. Also I don’t have enough information to make a meaningful response. However, there is this really good thread about building optimisation that may help explain how to reduce lag in your game:
How to improve your anti-exploit system
It looks like your system just checks if the players speed goes over 25 and as soon as that happens an action is taken against that player, I can’t be sure though. This is an okay way of doing it but this way has lots of flaws. For example, it doesn’t take into account sudden changes of speed because of lag. Maybe you could consider getting the players average speed over a certain amount of time and then checking if the player is speed exploiting from that average speed.
Sure. I’ll elaborate.
So, the game is based off the old TV show Endurance. People are grouped into pairs in the game, and have to compete in multiple challenges. Each round, the winners of the challenge can send 2 teams to compete against each other directly. Winning team of the 2 stays, while the other is eliminated.
The anti-exploit for when it detects speed is that it checks a player’s distance from their last recorded distance. If it’s over the max walkspeed set to it, it tells the server to warn the player that abnormal activity is possibly being detected on their device… If it occurs more than 7 times, the player’s kicked. I’ve since changed it to the max of 22 and checking intervals of 2.5.
Thank you for providing a little more information about your games general mechanics. I will be looking forward to seeing how your game turns out as it seems fun. Just generally do the things that I said in my original post to reduce lag. For example make sure you have no ‘taxing’/infinate loops or having lots of textures or decals lying around. Consider reading the topic I linked about building optimisations as it explains how to optimise builds far better than I can.
Maybe you could consider reading one of my older posts about designing for mobile users: