Improving my dash system?

I made a dash system but its honestly bad im trying to improve it

Code:

 local module = {}
local CommandData =		game:GetService("ReplicatedStorage"):WaitForChild("Remotes"):WaitForChild("CommandData")
local rus = game:GetService("RunService")
local CBM = require(script.Parent.ConnectedHitboxModule)
local event = game:GetService("ReplicatedStorage"):WaitForChild("Remotes"):WaitForChild("DashHitReg")
local circle  = 	game:GetService("ReplicatedStorage"):WaitForChild("Remotes"):WaitForChild("VFXTransfer"):WaitForChild("DashCircle")
local ts = game:GetService("TweenService")
local keyframe = game:GetService("ReplicatedStorage"):WaitForChild("Remotes"):WaitForChild("KeyframeClient")
local dashSFXEvent = game:GetService("ReplicatedStorage"):WaitForChild("Remotes"):WaitForChild("DashSFX")

local VFXREMOTE = game:GetService("ReplicatedStorage"):WaitForChild("Remotes"):WaitForChild("GM"):WaitForChild("DashVFXRemote")
function lerp(a, b, t)
	return a + (b - a) * t
end


function quadraticBezier(t, p0, p1, p2)
	local l1 = lerp(p0, p1, t)
	local l2 = lerp(p1, p2, t)
	local quad = lerp(l1, l2, t)
	return quad
end

local dashAnims = game:GetService("ReplicatedStorage"):WaitForChild("Animations"):WaitForChild("dashAnims")


function module.FrontDash(Character,Speed)
	
	local speed = Speed
	
	local x = 0 ;
	local Velocity = Instance.new("BodyVelocity",Character.HumanoidRootPart)
	
Velocity.MaxForce = Vector3.new(100000,0,100000)

	local Root = Character.HumanoidRootPart
	
	local Anim = Character.Humanoid.Animator:LoadAnimation(dashAnims.FrontDash)

	local pAnim = Character.Humanoid.Animator:LoadAnimation(dashAnims.FrontDashHit)

	Anim:AdjustWeight(0.001)
	pAnim:AdjustWeight(0.001)

circle:FireServer()
CBM.AddToPart(Character.HumanoidRootPart,Vector3.new(6,4,6),function(victim)
	
keyframe:FireServer(true)
		if x > 10  or victim:GetAttribute("Ragdoll") then
	
			Velocity:Destroy()

	
		speed = 30
	
	
		event:FireServer(victim,false)
		CBM.removeFromPart(Character.HumanoidRootPart)
		Anim:Stop()
	else
			speed = 30
		

			event:FireServer(victim,true)
			CBM.removeFromPart(Character.HumanoidRootPart)
			Anim:Stop()
		
	end
end,CFrame.new(0,2,0))

CBM.start(Character.HumanoidRootPart,Character.Humanoid)

Anim.Stopped:Connect(function()
	


	Velocity:Destroy()
	for i,v in Character.HumanoidRootPart:GetChildren() do
		
		
		if v:IsA("Part") and v.Name == "hitbox" then
			
			v:Destroy()
			
		end
		
		if v:IsA("WeldConstraint") and v.Name == "hitboxWeld" then
			
			v:Destroy()
			
		end
		
		
	end
	CBM.stop(Character.HumanoidRootPart)
		
end)


task.spawn(function()
	
	
	Anim:Play()

		
		while Velocity:IsDescendantOf(Character.HumanoidRootPart) do
	
		
			if x > 30 then 
				speed = 0
				
			Velocity:Destroy()
				Anim:Stop()
				keyframe:FireServer(false)
					Character.Humanoid.WalkSpeed = 0

			end
			
				VFXREMOTE:FireServer()
				
			
			
			local _,y = workspace.CurrentCamera.CFrame:ToOrientation()
			local X,_,z = Root.CFrame:ToOrientation()

			local cf = CFrame.new(Root.Position) * CFrame.Angles(X,y,z)
			Root.CFrame = cf

			x+=1
			print(x)
			print((-1/4)*math.pow(x,2)+80)
			Velocity.Velocity = (cf * 	CFrame.Angles(0,math.rad(0),0)).LookVector * (-2*x+100)
			
			
			rus.Heartbeat:Wait()

			
			
			
			
		end
		
		Velocity:Destroy()
		
	end)
	
	

	
	
	
	
	
end





function module.SideDash(Character,Direction)
	


	local speed = 	90

	local Velocity = Instance.new("BodyVelocity",Character.HumanoidRootPart)

	Velocity.MaxForce = Vector3.new(100000,0,100000)
	local Root = Character.HumanoidRootPart

local Anim
	if Direction == -1 then
	 Anim = Character.Humanoid.Animator:LoadAnimation(dashAnims.RightDash)
	end
	if Direction == 1 then
		Anim = Character.Humanoid.Animator:LoadAnimation(dashAnims.LeftDash)
	end

	Anim:AdjustWeight(0.001)
	dashSFXEvent:FireServer("Side")
	Anim:Play()
	task.spawn(function()
	while Velocity:IsDescendantOf(Character.HumanoidRootPart) do
		speed -=3


		if speed < 1 then 
			speed = 0
				Velocity:Destroy()
			Anim:Stop()
				task.delay(0.05,function()
					
					if Character:GetAttribute("State") == "SideDashing" then
						CommandData:FireServer("State","idle")		

					end

					
				end)
		end
		local _,y = workspace.CurrentCamera.CFrame:ToOrientation()
		local x,_,z = Root.CFrame:ToOrientation()

		local cf = CFrame.new(Root.Position) * CFrame.Angles(x,y,z)
		Root.CFrame = cf

		Velocity.Velocity = (cf * 	CFrame.Angles(0,math.rad(90*Direction),0)).LookVector * speed


			rus.Heartbeat:Wait()





	end



end)

	
end

function module.BackDash(Character)
	
	
	local speed = 100

	local Velocity = Instance.new("BodyVelocity",Character.HumanoidRootPart)

	Velocity.MaxForce = Vector3.new(100000,0,100000)
	local Root = Character.HumanoidRootPart

	local Anim  = Character.Humanoid.Animator:LoadAnimation(dashAnims.BackDash)

	Anim:AdjustWeight(0.001)

	Anim:Play()
	task.spawn(function()
		
		while Velocity:IsDescendantOf(Character.HumanoidRootPart) do
			speed -=2


			if speed < 1 then 
				speed = 0
				Anim:Stop()
				Velocity:Destroy()
				task.delay(0.1,function()
					if Character:GetAttribute("State") == "Dashing" then
						CommandData:FireServer("State","idle")		

					end

				end)

			end
			local _,y = workspace.CurrentCamera.CFrame:ToOrientation()
			local x,_,z = Root.CFrame:ToOrientation()

			local cf = CFrame.new(Root.Position) * CFrame.Angles(x,y,z)
			Root.CFrame = cf

			Velocity.Velocity = (cf * 	CFrame.Angles(0,math.rad(180),0)).LookVector * speed


			rus.Heartbeat:Wait()






		end

		local mag = Velocity.Velocity.Magnitude
		local Root = Character.HumanoidRootPart
		local curmag = mag 
		local starttime = tick()
		local reset = false
		while Velocity:IsDescendantOf(Character) do 
			local _,y = workspace.CurrentCamera.CFrame:ToOrientation()
			local x,_,z = Root.CFrame:ToOrientation()

			local cf = CFrame.new(Root.Position) * CFrame.Angles(x,y,z)
			Root.CFrame = cf
			local curtime = (tick()-starttime)*3.5
			if mag <= 0 then
				if not reset then
					reset = true
					wait(.05)
					starttime = tick()
					curtime = .01
					curmag = 60
					mag = 60
				else 
					break
				end
			end
			Velocity.Velocity = cf.LookVector * -mag
			mag = quadraticBezier(curtime,curmag,30,10)
			wait()
		end
		Velocity:Destroy()

	end)
	
	
	
end






return module

also in studio its still “ok” but ingame its much worse