after i press Q to dash there is like 0.5 sec of lag then it start the move
heres the dashing script
UIS.InputBegan:Connect(function(input,isTyping)
if isTyping then return end
local function SAnim()
local animation = animator:LoadAnimation(Animations.Back)
if RunAnimation.IsPlaying == true then
RunAnimation:Stop()
animation:Play(0,1, .5)
animation.Stopped:Wait()
RunAnimation:Play(0,1, .5)
else
animation:Play(0,1, .5)
end
end
local function AAnim()
local animation = animator:LoadAnimation(Animations.Left)
if RunAnimation.IsPlaying == true then
RunAnimation:Stop(0,1, .5)
animation:Play()
animation.Stopped:Wait()
RunAnimation:Play(0,1, .5)
else
animation:Play()
end
end
local function WAnim()
local animation = animator:LoadAnimation(Animations.Front)
if RunAnimation.IsPlaying == true then
RunAnimation:Stop()
animation:Play(0,1, .5)
animation.Stopped:Wait()
RunAnimation:Play(0,1, .5)
else
animation:Play(0,1, .5)
end
end
local function DAnim()
local animation = animator:LoadAnimation(Animations.Right)
if RunAnimation.IsPlaying == true then
RunAnimation:Stop()
animation:Play(0,1, .5)
animation.Stopped:Wait()
RunAnimation:Play(0,1, .5)
else
animation:Play(0,1, 0.5)
end
end
if dashDeb == false then
if input.KeyCode == Enum.KeyCode.Q and UIS:IsKeyDown(Enum.KeyCode.W) or input.KeyCode == Enum.KeyCode.W and UIS:IsKeyDown(Enum.KeyCode.Q) then
WAnim()
elseif input.KeyCode == Enum.KeyCode.Q and UIS:IsKeyDown(Enum.KeyCode.A) or input.KeyCode == Enum.KeyCode.A and UIS:IsKeyDown(Enum.KeyCode.Q) then
if UIS.MouseBehavior == Enum.MouseBehavior.LockCenter then
AAnim()
else
WAnim()
end
elseif input.KeyCode == Enum.KeyCode.Q and UIS:IsKeyDown(Enum.KeyCode.D) or input.KeyCode == Enum.KeyCode.D and UIS:IsKeyDown(Enum.KeyCode.Q) then
if UIS.MouseBehavior == Enum.MouseBehavior.LockCenter then
DAnim()
else
WAnim()
end
elseif input.KeyCode == Enum.KeyCode.Q and UIS:IsKeyDown(Enum.KeyCode.S) or input.KeyCode == Enum.KeyCode.S and UIS:IsKeyDown(Enum.KeyCode.Q) then
if UIS.MouseBehavior == Enum.MouseBehavior.LockCenter then
SAnim()
else
WAnim()
end
end
if input.KeyCode == Enum.KeyCode.Q then
dashDeb = true
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {char}
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
local rayResult = workspace:Raycast(humRoot.Position,hum.MoveDirection * vars.DASH_DISTANCE,raycastParams)
local rayPos
if rayResult then
local part = rayResult.Instance
if part.CanCollide == true then
rayPos = rayResult.Position
else
rayPos = (humRoot.CFrame + (hum.MoveDirection * vars.DASH_DISTANCE)).Position
end
else
rayPos = (humRoot.CFrame + (hum.MoveDirection * vars.DASH_DISTANCE)).Position
end
local mover = Instance.new("BodyPosition",humRoot)
mover.MaxForce = Vector3.new(9999999,9999999,9999999)
mover.D = 100
mover.P = 1000
mover.Position = rayPos
debris:AddItem(mover,0.3)
local gyro = Instance.new("BodyGyro",humRoot)
gyro.MaxTorque = Vector3.new(9999999,9999999,9999999)
gyro.D = 100
gyro.P = 1000
gyro.CFrame = humRoot.CFrame
debris:AddItem(gyro,0.3)
spawn(function()
wait(vars.DASH_CD)
dashDeb = false
end)
end
end
end)