Humanoid.Running not returning an accurate speed

I’m not sure when it started, but I’ve only noticed it recently since I started working with humanoids again. The behavior for Humanoid.Running before this bug used to be it passed through a speed that was either the same value as the humanoid’s walkspeed, or something very very very close to it. Recently it seems to be passing through much lower values, and they dont seem to be consistent (I was getting values like 8.3, 7.6, 16, 10.4, 1.4, 0) where they should be in almost all cases 0 or the WalkSpeed.

Repro steps are really simple, just stick the code below in a LocalScript and run it from StarterPlayerScripts. Hit play solo and walk around, You’ll see the speed values printed in the output from Humanoid.Running. You can tap R with the script active and it will change the walkspeed, notice it doesn’t fire Humanoid.Running again with the new speed*

local players = game:GetService("Players")
local player = players.LocalPlayer
local mouse = player:GetMouse()

local keyDownConnection;
local keyUpConnection;

local function disconnectKeys()
	if keyDownConnection then
		keyDownConnection:disconnect()
		keyDownConnection = nil
	end
	
	if keyUpConnection then
		keyUpConnection:disconnect()
		keyUpConnection = nil
	end
end

local function setUpRun(char)
	local humanoid = char:WaitForChild("Humanoid")
	
	keyDownConnection = mouse.KeyDown:connect(function(key)
		if key == "r" then
			humanoid.WalkSpeed = 24
		end
	end)
	
	keyUpConnection = mouse.KeyUp:connect(function(key)
		if key == "r" then
			humanoid.WalkSpeed = 16
		end
	end)
	
	--this just keep it from spamming the output
	local last = -69420
	humanoid.Running:connect(function(speed)
		if speed ~= last then
			last = speed
			print(speed)
		end
	end)
end

player.CharacterAdded:connect(function(newChar)
	disconnectKeys()
	setUpRun(newChar)
end)

if player.Character then
	disconnectKeys()
	setUpRun(player.Character)
end

*cross post I guess for feature requests, if Humanoid.Running could also fire again when the speed of a humanoid changes while it’s moving. As it stands if you start walking then change the WalkSpeed, the character will change speeds, but Humanoid.Running won’t fire again with the new speed.

The beauty of this event was being able to get the speed of the character easily (and in most cases as an integer) and consistently without a loop, so it not passing through any consistent speeds really negates it’s usefulness.

2 Likes