So, i’m trying to make an Anti-cheat system, i have a Run system that runs entirely on the client side, so that means that its easily modifiable for exploiters, so what should i do?
i was thinking about save the player position in a variable, and then after some time see the player position again and compare these two values, or should i try use LinearVelocity? if no, what should i do?
Anyway, this is my code:
-- Function to handle stamina depletion while running
local function handleRunning()
while run and Stamina > 0 and run == true do
if Hum.MoveDirection.Magnitude > 0.1 then
Stamina = math.max(Stamina - 1, 0) -- Decrease stamina, ensuring it doesn't go below 0
print("Foi")
Label.Text = Stamina
Hum.WalkSpeed = 24
Remove_Event:FireServer()
task.wait(DepleteRate)
else
Stamina = math.min(Stamina + 1, 100) --If you are holding shift but you are not moving you can regen stamina, you can remove this if you want
Label.Text = Stamina
task.wait(RegenRate)
end
end
-- Function to handle stamina regeneration
local function handleRegeneration()
while not run and Stamina < 100 do
Stamina = math.min(Stamina + 1, 100) -- Increase stamina, ensuring it doesn't exceed 100
Label.Text = Stamina
task.wait(RegenRate)
end
end
-- Detect when the player starts running
UIS.InputBegan:Connect(function(io, gpe)
if io.KeyCode == Enum.KeyCode.LeftShift and not gpe and Stamina > 0 and run == false then
run = true
handleRunning()
end
end)
-- Detect when the player stops running
UIS.InputEnded:Connect(function(io, gpe)
if io.KeyCode == Enum.KeyCode.LeftShift and not gpe then
run = false
Hum.WalkSpeed = 16
handleRegeneration()
end
end)
this is what i wanted to say, if you know how to answer my question, i’m going to be happy to know.
Going off of what @Microlosofto said you need to make it server sided. Don’t waste your time making client side anti cheat. They can always be bypassed. The most you can do is make it less powerful for exploiters. Exploiters will always have an advantage over other players… it’s just that by making it server sided you can shrink this advantage to being much smaller compared to a client sided anti cheat where they will have an extremely unfair advantage.
I deleted a message because you confused me by saying to check the walkspeed in the local script. You cannot directly stop anything the player is doing using exploits. The best thing you can do is test both position checking and velocity checking and find which one works the best for you. This forum isn’t meant to spoon feed you but rather serves as a means of helping fill in the blanks so you can put the rest together.
Also don’t take my word for it. Obviously use an alt account for this. If you go on Jailbreak and run a fly script for example… the game will knock you back if you fly too quickly. If you go nice and slow with it, you can fly. But there’s a limit. That’s what you can do. Jailbreak would never do it that way if Roblox let people check the walkspeed property. That’s the whole point. That’s what we’re stuck with.
you’re welcome! Understanding everything is crucial to being a developer. There are certain rules in Roblox that should be changed and improved upon but Roblox doesn’t care enough to do that for us. I believe in doing whatever it takes within reason and ethics to understand things so that you can use that knowledge for good things.