I can dash in any diagonal using right but can't dash using left

No matter what, even if I use shiftlock, I can’t dash in any diagonal direction using left. The game doesn’t even register me attempting to dash. I’ve tried in another script to see if any diagonal using left works and it worked flawlessly. I’ve tried script diagonals individually, but I have the same problem.

wait(1)
local Movement = {
	["Sprint"] = function(Player, Params)

	end,
	["Dash"] = function(Player, Params, UserInput)
		local RS = game:GetService("RunService")
		local Debris = game:GetService("Debris")
		local RunService = game:GetService("RunService")
		local UserInputService = game:GetService("UserInputService")
		
		local player = game.Players.LocalPlayer
		local character = player.Character
		local humanoid = character:WaitForChild("Humanoid")
		local HRP = character:FindFirstChild("HumanoidRootPart")
		
		local keys = {
			["Forward"] = UserInputService:IsKeyDown(Enum.KeyCode.W),
			["Backwards"] = UserInputService:IsKeyDown(Enum.KeyCode.S),
			["Right"] = UserInputService:IsKeyDown(Enum.KeyCode.D),
			["Left"] = UserInputService:IsKeyDown(Enum.KeyCode.A)
		}
		
		local roll = {
			ForwardRoll = humanoid:LoadAnimation(script:WaitForChild("ForwardRoll")),
			BackwardsRoll = humanoid:LoadAnimation(script:WaitForChild("BackwardsRoll")),
			RightDash = humanoid:LoadAnimation(script:WaitForChild("RightDash")),
			LeftDash = humanoid:LoadAnimation(script:WaitForChild("LefttDash"))			
		}
		
		local duration = roll.ForwardRoll.Length
		local _, pitch, _ = HRP.CFrame:ToOrientation()
		local bodyVelocities = {}
		local ShiftLocked = false
		
		local function Velocity(multiplier, velocity)
			multiplier = 0
			if keys["Forward"] then
				multiplier = 3.125
				print("F")
			elseif keys["Backwards"] then
				multiplier = -3.125
				print("B")
			elseif keys["Right"] then
				multiplier = 3.125
				print("R")
			elseif keys["Left"] then
				multiplier = -3.125
				print("L")
			end
			
			velocity = humanoid.WalkSpeed * multiplier
			
			return velocity
		end
		
		local velocity = humanoid.WalkSpeed * 3.125
		local calculatedVelocity = Velocity(0, keys)
		
		local function Roll()
			if humanoid.FloorMaterial ~= Enum.Material.Air then
				humanoid.UseJumpPower = false
				
				local bodyVelocity = Instance.new("BodyVelocity")
				bodyVelocity.MaxForce = Vector3.new(99999,0,99999)
				bodyVelocity.Parent = HRP
				
				if not ShiftLocked then
					bodyVelocity.Velocity = HRP.CFrame.LookVector * velocity * 10 / humanoid.WalkSpeed
				elseif keys["Right"] or keys["Left"] and ShiftLocked then
					bodyVelocity.Velocity = HRP.CFrame.RightVector * calculatedVelocity * 10 / humanoid.WalkSpeed
				elseif keys["Forward"] or keys["Backwards"] and ShiftLocked then
					bodyVelocity.Velocity = HRP.CFrame.LookVector * calculatedVelocity * 10 / humanoid.WalkSpeed
				end
				
				table.insert(bodyVelocities, bodyVelocity)
				
				while roll.ForwardRoll.isPlaying or roll.BackwardsRoll.isPlaying or roll.RightDash.isPlaying or roll.LeftDash.isPlaying  do
					local _, newPitch, _ = HRP.CFrame:ToOrientation()
					
					if pitch ~= newPitch then
						if #bodyVelocities > 0 then
							bodyVelocities[#bodyVelocities]:Destroy()
							table.remove(bodyVelocities, #bodyVelocities)
						end
						
						local bodyVelocity = Instance.new("BodyVelocity")
						bodyVelocity.MaxForce = Vector3.new(99999,0,99999)
						bodyVelocity.Parent = HRP
						
						if not ShiftLocked then
							bodyVelocity.Velocity = HRP.CFrame.LookVector * velocity * 10 / humanoid.WalkSpeed
						elseif keys["Right"] or keys["Left"] and ShiftLocked then
							bodyVelocity.Velocity = HRP.CFrame.RightVector * calculatedVelocity * 10 / humanoid.WalkSpeed
						elseif keys["Forward"] or keys["Backwards"] and ShiftLocked then
							bodyVelocity.Velocity = HRP.CFrame.LookVector * calculatedVelocity * 10 / humanoid.WalkSpeed
						end

						table.insert(bodyVelocities, bodyVelocity)

					end

					wait(0.05)
				end


				bodyVelocities[#bodyVelocities].Velocity *= 0.9

				humanoid.UseJumpPower = true

				for _, bodyVelocity in ipairs(bodyVelocities) do
					bodyVelocity:Destroy()
				end
			end
		end
		
		local function Shiftlocked()
			if keys["Forward"] then
				roll.ForwardRoll:Play()
				Roll()
				print("forward")
			elseif keys["Backwards"] then
				roll.BackwardsRoll:Play()
				Roll()
				print("backward")
			elseif keys["Right"] then
				roll.RightDash:Play()
				Roll()
				print("play")
			elseif keys["Left"] then
				roll.LeftDash:Play()
				Roll()
				print("play")
			end
		end
		
		if UserInputService.MouseBehavior == Enum.MouseBehavior.LockCenter then
			ShiftLocked = true
			Shiftlocked()
		elseif UserInputService.MouseBehavior == Enum.MouseBehavior.Default or UserInputService.MouseBehavior == Enum.MouseBehavior.LockCurrentPosition then
			ShiftLocked = false
			roll.ForwardRoll:Play()
			Roll()
		end
	end,
}

return Movement

1 Like

There are no replies :sob: :sob: :sob: :sob: :sob: :sob: :sob:

You only made options for those. Add extra options for diagonal.

["ForwardLeft"] = UserInputService:IsKeyDown(Enum.KeyCode.W) and UserInputService:IsKeyDown(Enum.KeyCode.A)

then:

elseif keys["ForwardLeft"] then
    multiplier = --multiplier
    print("FL")
end

I knew it wouldn’t work, but I tried it anyway. The script is written in a way that diagonals should work, and diagonal right does work but diagonal left doesn’t. This solution doesn’t work because the script doesn’t even recognize using two inputs because when I try to dash diagonally if I’m holding W and D for example it would see it as dashing forward

It’s probably registering that you pressed one of the keys first, even if it doesn’t seem like it from your point of view. It all happens so fast, it registers one of the keys, and stops listening for other keys once one has been pressed. You could add a small wait time to listen for other keys being pressed before continuing.

this works

if keys["Right"] and keys["Forward"] then
					bodyVelocity.Velocity = HRP.CFrame.LookVector * velocity * 10 / humanoid.WalkSpeed
					print("a")
				elseif not ShiftLocked then
					bodyVelocity.Velocity = HRP.CFrame.LookVector * velocity * 10 / humanoid.WalkSpeed
				elseif keys["Right"] or keys["Left"] and ShiftLocked then
					bodyVelocity.Velocity = HRP.CFrame.RightVector * calculatedVelocity * 10 / humanoid.WalkSpeed
				elseif keys["Forward"] or keys["Backwards"] and ShiftLocked then
					bodyVelocity.Velocity = HRP.CFrame.LookVector * calculatedVelocity * 10 / humanoid.WalkSpeed
				end

but this doesnt

if keys["Left"] and keys["Forward"] then
					bodyVelocity.Velocity = HRP.CFrame.LookVector * velocity * 10 / humanoid.WalkSpeed
					print("a")
				elseif not ShiftLocked then
					bodyVelocity.Velocity = HRP.CFrame.LookVector * velocity * 10 / humanoid.WalkSpeed
				elseif keys["Right"] or keys["Left"] and ShiftLocked then
					bodyVelocity.Velocity = HRP.CFrame.RightVector * calculatedVelocity * 10 / humanoid.WalkSpeed
				elseif keys["Forward"] or keys["Backwards"] and ShiftLocked then
					bodyVelocity.Velocity = HRP.CFrame.LookVector * calculatedVelocity * 10 / humanoid.WalkSpeed
				end

probably a little late, but who cares, sorry for bump.

you can achive the exact same effect your going for by just using Humanoid.MoveDirection, its way easier to understand and works really well.

here i have just ripped the code from a dash script on the toolbox, and adjusted one line of the script to make it 10x better, and you can get it working with mobile since it used MoveDirection.


Edited script

-- Put "Slide Ability" in StarterPlayer and StarterCharacterScripts
--                        Enjoy This Ability

local UIS = game:GetService("UserInputService")
local char = script.Parent

local slideAnim = Instance.new("Animation")
slideAnim.AnimationId = "rbxassetid://6692601621" -- Enter your AnimtionID

local keybind = Enum.KeyCode.E -- between the key for ability
local canslide = true

UIS.InputBegan:Connect(function(input,gameprocessed)
	if gameprocessed then return end
	if not canslide then return end
	
	if input.KeyCode == keybind then
		canslide = false
		
		local playAnim = char.Humanoid:LoadAnimation(slideAnim)
		playAnim:Play()
		
		local slide = Instance.new("BodyVelocity")
		slide.MaxForce = Vector3.new(1,0,1) * 30000
		slide.Velocity = char.Humanoid.MoveDirection * 100
		slide.Parent = char.HumanoidRootPart
		
		for count = 1, 8 do
			wait(0.1)
			slide.Velocity*= 0.7
		end
		playAnim:Stop()
		slide:Destroy()
		canslide = true
	end
end)

Original script

	-- Put "Slide Ability" in StarterPlayer and StarterCharacterScripts
--                        Enjoy This Ability

local UIS = game:GetService("UserInputService")
local char = script.Parent

local slideAnim = Instance.new("Animation")
slideAnim.AnimationId = "rbxassetid://6692601621" -- Enter your AnimtionID

local keybind = Enum.KeyCode.E -- between the key for ability
local canslide = true

UIS.InputBegan:Connect(function(input,gameprocessed)
	if gameprocessed then return end
	if not canslide then return end
	
	if input.KeyCode == keybind then
		canslide = false
		
		local playAnim = char.Humanoid:LoadAnimation(slideAnim)
		playAnim:Play()
		
		local slide = Instance.new("BodyVelocity")
		slide.MaxForce = Vector3.new(1,0,1) * 30000
		slide.Velocity = char.HumanoidRootPart.CFrame.lookVector * 100
		slide.Parent = char.HumanoidRootPart
		
		for count = 1, 8 do
			wait(0.1)
			slide.Velocity*= 0.7
		end
		playAnim:Stop()
		slide:Destroy()
		canslide = true
	end
end)
		
		

Also i recommend you use LinearVelocity instead because BodyVelocity is depricated, though it is really difficult to get LinearVelocity working like BodyVelocity, im pretty sure i made a post about how to get it working like BodyVelocity a while ago, so use that if you want too.

You can compare them if you want.

Hoped i could have helped! bye!

I completely forgot about this thread. The issue was with my keyboard xD.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.