So it really depends on the type of exploit they’re using.
Flying exploits I just have a script inserted into their character that checks their humanoid.Floor and I set a variable to count u[ by +1 for every second that a player is in the air. So 3 seconds or so is a bit of time to stay in the air (unless you have a high JumpHeight then it could take 3+ seconds to fall back down to the ground.)
So I check for FloorMaterial like this:
--This assumes script.Parent.Parent is the character then fetch the humanoid
local airTime = 0
local humanoid = script.Parent.Parent:FindFirstChildOfClass("Humanoid")
--0 is the quickest number a loop can go, you could also just do 1 for every second.
while true do task.wait(0)
if humanoid.FloorMaterial == Enum.Material.Air then
if airTime >= 3 then
print("Player has been in the air for 3 full seconds. Likely hacking.")
elseif airTime < 3 then
airTime += 1
task.wait(1)
end
else
airTime = 0
end
end
Note: The anove script uses a normal loop. I only did this as an example, and it’s really not best practice. Anyone could jump and the loop might not register that they touched the floor within that amount of time, and it could potentially give a false-positive of them being a hacker.
For best use please use os.Time. The above script was a quick example I wrote into this DevForum comment.
Also another way I would prevent exploiting is if you’re checking for a movement-based exploit such as running and your game, as you’ve stated, gives +1 speed every second or so, then that’s actually what you should be checking.
If you give players +1 speed every second and you want to check to see if they’ve exploiting the game, store their total play-time somewhere. Even if it’s just a value in the leaderstats.
You can check this by doing something similar to the script above like this:
--This assumes script.Parent.Parent is the character then fetch the humanoid
local airTime = 0
local humanoid = script.Parent.Parent:FindFirstChildOfClass("Humanoid")
--0 is the quickest number a loop can go, you could also just do 1 for every second.
--Gets the player's character
local playerCharacter = script.Parent.Parent
local players = game:GetService("Players")
--Gets the player from the referenced character
local player = players:GetPlayerFromCharacter(playerCharacter)
--fetches your leaderstats
local leaderstats = player:FindFirstChild("leaderstats")
local playTime = player:FindFirstChild("PlayTime")
local defaultSpeed = 16
--Calculates the speed. If playTime is 0 then speed will be 16. If playtime is 1 then speed will be 17. Continues.
local calculatedSpeed = playTime.Value+defaultSpeed
while true do task.wait(0)
if humanoid.Walkspeed > calculatedSpeed then
print("They are likely hacking. Their speed is greater than the speed collected from time.")
else
--It would be less than or equal if you give players the option to set their speed.
print("Their speed is <= calculatedSpeed.")
end
end
Note: Keep in mind that if you use conveyors, they are known to glitch. Sometimes conveyors that move the characters can accidentally fling a player across the map or something, and so this gives a false-positive and makes the system think the player is exploiting.
^ Not that you’re using conveyors or anything, I mean some games do but I just wanted to note that here.
(That also depends on your system and if you decide to use a script that checks the playerCharacter’s position.)
I hope this helps, let me know! I noticed someone had an estimated time and if you decide to use my speed approach then you wouldn’t have to estimate how quickly they should finish the race. You can just literally compare it to how long they’ve been in-game for and check the speed they’re allowed.
Also I noticed the answer that @TheFaeTwins gave, and this is a very good approach to this. One thing I would challenge this with is this:
- What’s stopping the game from accidently flinging the player across the map and then giving them a punishment?
- Also if collisions are on, faster players could potentially help push a slower player (maybe their friend) across the map by pushing against them.
Please note that I’m not attacking your comment, I’m just thinking about it in a very “what could go wrong, or what unexpected issues or outcomes can occur?” way.
You could even combine these two checks.
- On race completion check to see if it’s suspicious.
- If it’s suspicious then check the walkspeed.
- If the walkspeed is totally normal then it was likely a glitch, fling, accident, or a potential teleport exploit. but totally if their walkspeed is greater than what’s actually allowed for them then it’s way likely a hack.