Roll-Jump animation script does not like me

I made a roll-jump script, where if you roll, it shoots you forward, plus you can jump out of the roll to keep some of the speed.
This works, but the speed kind of only applies during the end of the roll animation for some reason.
how do i make it so the velocity gets applied when you jump out of the roll at any time.

local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char:WaitForChild('Humanoid')
local jumps = 1
local max = 2
local isjump = false
local currenttick = tick()
local db = false
local canjump = true
local isrolling = false
if humanoid then
	local slideAnim = Instance.new("Animation")
	slideAnim.AnimationId = "rbxassetid://12868749863"
	local jumpAnim = Instance.new('Animation')
	jumpAnim.AnimationId = "rbxassetid://12900868359"
	local landAnim = Instance.new('Animation')
	landAnim.AnimationId = "rbxassetid://12901080333"
	local function onstateChanged(oldstate,newstate)
		
		
		if Enum.HumanoidStateType.Landed == newstate then
			wait(0.2)
			jumps = 1
			db = false
		end
		
		if Enum.HumanoidStateType.Freefall == newstate then
			wait(0.2)
			db = true
			isrolling = false
		end
		
			
		if Enum.HumanoidStateType.Jumping == newstate then
			db = false
			jumps +=1
		end
	end
	local playAnim = humanoid:LoadAnimation(slideAnim)
	local function onJump()
		local jumpanimation = humanoid:LoadAnimation(jumpAnim)
		local landanimation = humanoid:LoadAnimation(landAnim)
		if db == false and isrolling == true then
			slideAnim:Destroy()
			jumpanimation:Play()
			local slide2 = Instance.new("BodyVelocity")
			slide2.MaxForce = Vector3.new(0.5,0,0.5) * 30000
			slide2.Velocity = char.HumanoidRootPart.CFrame.lookVector * 40
			slide2.Parent = char.HumanoidRootPart
			if humanoid.FloorMaterial == Enum.Material.Air then
				
				print("Huh")
				if jumps < max and tick() > 0.5 then
					humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
					print("WHAT")
					currenttick = tick()
					if Enum.HumanoidStateType.Landed then
						jumpAnim:Destroy()
						slide2:Destroy()
					end
					wait(0.3)
					jumpAnim:Destroy()
					slide2:Destroy()
				end
				
			end
			print('Jumping')
			wait(0.5)
			if Enum.HumanoidStateType.Landed then
				jumpAnim:Destroy()
				slide2:Destroy()
			end
			print('END')
			wait(0.3)
			jumpAnim:Destroy()
			slide2:Destroy()
		end
	end
	

	local keybind = Enum.KeyCode.LeftShift
	local canslide = true

	UIS.InputBegan:Connect(function(input,gameprocessed)
		if gameprocessed then return end
		if not canslide then return end
		if humanoid.FloorMaterial == Enum.Material.Air then
			return
		end
		if input.KeyCode == keybind then
			canslide = false
			isrolling = true

			local playAnim = humanoid:LoadAnimation(slideAnim)
			playAnim:Play()
			UIS.JumpRequest:Connect(onJump)
			humanoid.StateChanged:Connect(onstateChanged)
			local sound = Instance.new('Sound')
			sound.Name = "bob"
			sound.Parent = char.HumanoidRootPart
			sound.SoundId = "rbxassetid://7545317681"
			sound:Play()

			local slide = Instance.new("BodyVelocity")
			slide.MaxForce = Vector3.new(0.5,0,0.5) * 30000
			slide.Velocity = char.HumanoidRootPart.CFrame.lookVector * 60
			slide.Parent = char.HumanoidRootPart
			wait(0.4)
			local canjump = false
			playAnim:Stop()
			slide:Destroy()
			wait(0.5)
			canslide = true
		end
	end)

end

You could use ApplyImpulse or AssemblyLinearVelocity

The rest of the code runs only when the animation itself has ended, you can either use another localScript and run it simultaneously or maybe have it called to a remote event (or perhaps apply the velocity before the animation)