So, i have this script for dashing and whenever the player dashes in the air, the animations looks like trash lol
So i wanted a way to disable the jump animation when dashing but enable it back when not dashing
i’ve tried changing the character’s “Animate” script but it looks bad when the player is just jumping without dashing
local UIS = game:GetService("UserInputService")
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local player = Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local rootPart = char:WaitForChild("HumanoidRootPart")
local dashSpeed = 2000
local maxSpeed = 150
local groundBoost = 2
local dashTime = 0.5
local dashDelay = 0.7
local canDash = true
local leftDashAnim = "rbxassetid://117474809877047"
local rightDashAnim = "rbxassetid://129857834813992"
local anim = humanoid:FindFirstChildOfClass("Animator") or Instance.new("Animator", humanoid)
local leftAnim = Instance.new("Animation")
leftAnim.AnimationId = leftDashAnim
local leftTrack = anim:LoadAnimation(leftAnim)
local rightAnim = Instance.new("Animation")
rightAnim.AnimationId = rightDashAnim
local rightTrack = anim:LoadAnimation(rightAnim)
local gui = player:WaitForChild("PlayerGui"):FindFirstChild("DashUI")
if not gui then return end
local coolFrame = gui:FindFirstChild("CooldownFrame")
local fillBar = coolFrame:FindFirstChild("FillFrame")
local function isOnGround()
return humanoid.FloorMaterial ~= Enum.Material.Air
end
local function doDash(dir)
if not canDash then return end
canDash = false
local origJump = humanoid.JumpPower
humanoid.JumpPower = 0
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
fillBar.Size = UDim2.new(0, 0, 1, 0)
task.spawn(function()
for i = 0, 1, 0.01 do
fillBar.Size = UDim2.new(i, 0, 1, 0)
task.wait(dashDelay / 100)
end
fillBar.Size = UDim2.new(1, 0, 1, 0)
canDash = true
end)
local dashForce = dashSpeed
if isOnGround() then
dashForce = dashSpeed * groundBoost
end
if dashForce > maxSpeed then
dashForce = maxSpeed
end
local dashDir = rootPart.CFrame.RightVector * dir
local dashVel = dashDir * dashForce
local newVel = Vector3.new(dashVel.X, rootPart.Velocity.Y, dashVel.Z)
rootPart.Velocity = newVel
if dir < 0 then
leftTrack:Play()
elseif dir > 0 then
rightTrack:Play()
end
task.wait(dashTime)
leftTrack:Stop()
rightTrack:Stop()
humanoid.JumpPower = origJump
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
end
UIS.InputBegan:Connect(function(input, processed)
if processed then return end
if input.KeyCode == Enum.KeyCode.LeftControl then
local moveDir = humanoid.MoveDirection
local rightVec = rootPart.CFrame.RightVector
local dotProd = moveDir:Dot(rightVec)
if dotProd > 0 then
doDash(1)
elseif dotProd < 0 then
doDash(-1)
end
end
end)