How to make an run that adapts combat?

so im trying to make an run. but that should be like if character got hit, reset to walk. but i dont know how.

use a script to check if the player’s health was changed with the healthchanged function and if it is lower than the current health, then set the walk speed back to 16 (or the normal walk speed of your game) like this

local Players = game:GetService('Players')

-- Function to handle player health changes
local function handleHealthChange(player, newHealth, prevHealth)
	-- Check if the player's health has decreased and not healed
	if newHealth < prevHealth then
		-- Set player's walkspeed back to 16
		local character = player.Character
		if character then
			local humanoid = character:FindFirstChildOfClass("Humanoid")
			if humanoid and humanoid.WalkSpeed > 16 then
				humanoid.WalkSpeed = 16
			end
		end
	end
end

-- Listen for changes in the player's health for each player's character
for _, player in ipairs(Players:GetPlayers()) do
	local character = player.Character
	if character then
		local humanoid = character:WaitForChild("Humanoid")
		local prevHealth = humanoid.Health

		humanoid.HealthChanged:Connect(function(newHealth)
			handleHealthChange(player, newHealth, prevHealth)
			prevHealth = newHealth
		end)
	end
end

you can put this in startercharacterscripts