Players speed wont change and animation wont stop

I have a sprinting script and I was testing if stun would make the animation stop and the character would stop moving but it doesn’t, here’s my script I have no clue whats wrong with it,

local Humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
local UIS = game:GetService('UserInputService')
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://8953662262"
local plr = game.Workspace:WaitForChild(game.Players.LocalPlayer.Name)
local Run = Humanoid:LoadAnimation(animation)
local S,Word,Running = " ", "W",false

UIS.InputBegan:Connect(function(Input,IsTyping)
	if IsTyping then return end
	if Input.KeyCode == Enum.KeyCode[Word] then
		S = S..Word
	end

	delay(.3, function()
		if S ~= string.rep(Word,2) then S = "" end
	end)

	if S == tostring(Input.KeyCode):gsub("Enum.KeyCode.",Word) then
		if plr.CanSprint.Value == true then
			plr.IsSprinting.Value = true
		
		Running = true
		Run:Play()
			Humanoid.WalkSpeed = 32
		end
	end

	local ChangeEnd = UIS.InputEnded:Connect(function(Input)
		if Input.KeyCode == Enum.KeyCode[Word] then
			if S ~= Word then Running = false end
		end
	end)

	repeat wait() until Running == false or plr.IsSprinting.Value == false
	plr.IsSprinting.Value = false
	ChangeEnd:Disconnect()
	Run:Stop()
	Humanoid.WalkSpeed = 16
	
end)

Heres the script in the part I was testing stun with

function touch(hit)
	hit.Parent:FindFirstChild("Humanoid").Parent.IsSprinting.Value = false
	print("stopped")
	print(hit.Parent:FindFirstChild("Humanoid").Parent.IsSprinting.Value)
end

script.Parent.Touched:connect(touch)