Best way to do a sprint system?

Hello,

I am wondering, what is the best way to make a sprint system? I want it to be optimized and not exploitable. In the past, I’ve used a single local script to detect player input, but Ive come to realize that this is easily exploitable. I feel like an optimized sprint system probably involves a remote event or remote function, but im not sure which one or how to go about that. Any help is appreciated!

Note: I found a post similar to this one, but it was a little bit too vague.

in my sprint system I obtain the input from the client then play the animation and do the rest of the work on the server.

Don’t waste your time tryna make an “anti exploitable sprint system”. If someone wants to use speed exploits, they going to do it, whether you have a sprint system in or not. Make something that’s simple and reliable. NEVER waste your time tryna write code to “cater” to the 0.001% of players who are going exploit

I normally just get the input events and do whatever needs to be done on the client (camera effects, etc) and then fire an event to deal with the walkspeed, anyway this is still exploitable, but i like setting speed on the server to not cause any weird issues with server > client communication, if you want to make it non exploitable you will need to detect if the player is moving faster than expected, and then deal with them. (but dont ban them right away as this can sometimes be faulty, you should ban them if it happens alot in a short time)

I just do most movement related stuff on client, since if a cheater wants to move fast they could just increase their walkspeed. Also often times doing sprint related things on the server feels sluggish on the client because of the delay.

I’ve made so many versions of a sprint and they all are exploitable in some way. Other than this one. More of an increasing speed that resets. Fully self contained, requires nothing else, and is not exploitable. In fact, it resists exploiting.

--ServerScript in ServerScriptService
local maxSpeed = 20.1
local speedIncrement = 1
local defaultWalkSpeed = 16
local rs = game:GetService("RunService")

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local humanoid = character:WaitForChild("Humanoid")
		local isRunning = false

		local function updateSpeed()
			if humanoid.WalkSpeed<maxSpeed then
				humanoid.WalkSpeed=math.min(humanoid.WalkSpeed+speedIncrement,maxSpeed)
			end
		end

		local function resetSpeed()
			humanoid.WalkSpeed=defaultWalkSpeed
		end
		
		repeat task.wait(3)
		until humanoid.MoveDirection~=Vector3.zero
		
		while true do
			local speed=humanoid.MoveDirection.Magnitude * humanoid.WalkSpeed
			isRunning=speed > 0.1
			if isRunning then
				updateSpeed()
			else resetSpeed()
			end	task.wait(0.5)
		end
	end)
end)

this is absolutely how everyone should think, sure u might want to add some security but not completely maximize on it. Unfortunately the ppl with this mindset are very hard to be talked out of it.