If player > run speed over?

Is there a way to make so when a player runs over a certain amount of speed that he will start a timer?
if there is could you please tell me? c:

Edit:
I’m trying to make a stamina bar for my Gamemode.

Since it’s christmas, here some raw code, it needs to be ran on both the client and the server:

[lua]
local chargeSkip = false
local function stamina()
for k, v in pairs(player.GetAll()) do
if CLIENT and v != LocalPlayer() then continue end

	v.Stamina = v.Stamina or 100

	if v:KeyDown( IN_SPEED ) then
		if v.Stamina == 0 then
			if SERVER then v:SprintDisable() end
		else
			v.Stamina = v.Stamina - 1
			if SERVER then v:SprintEnable() end
		end
	elseif v.Stamina < 100 then
		if v:KeyDown(IN_FORWARD) or v:KeyDown(IN_BACK) or v:KeyDown(IN_LEFT) or v:KeyDown(IN_RIGHT) or v:KeyDown(IN_MOVELEFT) or v:KeyDown(IN_MOVERIGHT) or v:KeyDown(IN_JUMP) then
			if chargeSkip == false then
				v.Stamina = v.Stamina + 1
				chargeSkip = true
			else
				chargeSkip = false
			end
		else
			v.Stamina = v.Stamina + 1
		end
	end

	if CLIENT and v == LocalPlayer() then break end
end

end
timer.Create(“stamina”, 0.1, 0, stamina)

if SERVER then
/* fixes */
local meta = FindMetaTable(“Player”)

function meta:SprintEnable()
	self:SetRunSpeed(300)
end

function meta:SprintDisable()
	self:SetRunSpeed(160)
end

end
[/lua]

You can access a player’s stamina from their player object on both realms (player.Stamina). You’ll also need to change the run/walk speeds to your own preference.

thank you :slight_smile: