Hello everyone i have this simple script right here wich is a dash system but i found out if we dashed backwards without jumping before and smash the space bar it will just fling the player
Here’s what i mean :
Here’s the script :
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local huamnoid = character:WaitForChild("Humanoid")
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
local replicatedStorage = game:GetService("ReplicatedStorage")
local cooldownBindableEvent = replicatedStorage.CooldownEvents:WaitForChild("Cooldown")
local forwardDash = huamnoid:LoadAnimation(script:WaitForChild("ForwardDash"))
local backwardDash = huamnoid:LoadAnimation(script:WaitForChild("BackwardDash"))
local leftDash = huamnoid:LoadAnimation(script:WaitForChild("LeftDash"))
local rightDash = huamnoid:LoadAnimation(script:WaitForChild("RightDash"))
local Debris = game:GetService("Debris")
local UIS = game:GetService("UserInputService")
local debounce = false
UIS.InputBegan:Connect(function(input,gpe)
if gpe then return end
if input.KeyCode == Enum.KeyCode.C and player:GetAttribute("isStunned") == false and player:GetAttribute("isBlocking") == false and player:GetAttribute("isAttacking") == false and debounce == false then
debounce = true
local linearVelocity = Instance.new("LinearVelocity",humanoidRootPart)
linearVelocity.Attachment0 = humanoidRootPart:WaitForChild("RootAttachment")
linearVelocity.MaxForce = math.huge
if UIS:IsKeyDown(Enum.KeyCode.W) then
forwardDash:Play()
linearVelocity.VectorVelocity = humanoidRootPart.CFrame.LookVector.Unit * 50
elseif UIS:IsKeyDown(Enum.KeyCode.S) then
backwardDash:Play()
linearVelocity.VectorVelocity = humanoidRootPart.CFrame.LookVector.Unit * -50
elseif UIS:IsKeyDown(Enum.KeyCode.D) then
leftDash:Play()
linearVelocity.VectorVelocity = humanoidRootPart.CFrame.RightVector.Unit * 50
elseif UIS:IsKeyDown(Enum.KeyCode.A) then
rightDash:Play()
linearVelocity.VectorVelocity = humanoidRootPart.CFrame.RightVector.Unit * -50
end
cooldownBindableEvent:Fire("Dash",2)
Debris:AddItem(linearVelocity,.3)
task.wait(2)
debounce = false
end
end)