Walkspeed doesn't change after character death

The script works fine before resetting my character, I can toggle run on and off.
But after I respawn nothing happens.

local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local UIS = game:GetService("UserInputService")
local speed = humanoid.WalkSpeed
Running = false

UIS.InputBegan:Connect(function(input, g)
	if not g then
	if input.KeyCode == Enum.KeyCode.LeftControl then
		if Running == false then
			humanoid.WalkSpeed = 32
			print(humanoid.WalkSpeed)
			Running = true
		elseif Running == true then
			humanoid.WalkSpeed = 16
			print(humanoid.WalkSpeed)
			Running = false
		end
	end
	end
end)

image
It prints that the walkspeed is 32 even though Iā€™m not faster.

1 Like

Do you have the script in StarterPlayerScripts or StarterCharacterScripts? Since you are getting the Humanoid once, it should be in StarterCharacterScripts. Your code is working perfectly on my end.

1 Like