how am i able to make this working dash system to only be able to dash left and right, i have 2d movement but if i try dashing then pressing d right after it starts going front n shi `local uis = game.UserInputService
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local key = Enum.KeyCode.C
local boostAnim = Instance.new("Animation")
boostAnim.AnimationId = "rbxassetid://110269833815516"
local animator = hum:WaitForChild("Animator")
local currentAnimTrack = nil
local dashSound = Instance.new("Sound")
dashSound.SoundId = "rbxassetid://5989939664"
dashSound.Parent = char:WaitForChild("HumanoidRootPart")
local function playAnimation()
if not currentAnimTrack or not currentAnimTrack.IsPlaying then
currentAnimTrack = animator:LoadAnimation(boostAnim)
currentAnimTrack:Play()
end
end
local function stopAnimation()
if currentAnimTrack and currentAnimTrack.IsPlaying then
currentAnimTrack:Stop()
end
end
local function playDashSound()
dashSound:Play()
end
uis.InputBegan:Connect(function(inp, gpe)
if inp.KeyCode == key and not gpe then
hum.WalkSpeed = 20
local bv = Instance.new("BodyVelocity", char:FindFirstChild("HumanoidRootPart"))
bv.P = 1000
bv.MaxForce = Vector3.new(99999, 99999, 99999)
bv.Velocity = char:FindFirstChild("HumanoidRootPart").CFrame.LookVector * 100
game.Debris:AddItem(bv, 0.1)
playAnimation()
playDashSound()
end
end)
uis.InputEnded:Connect(function(inp, gpe)
if inp.KeyCode == key and not gpe then
hum.WalkSpeed = 16
wait(0.5)
stopAnimation()
end
end)
`
** You are now Level 9! **