Bug with The Dash Script

I have no idea on how to fix this. I tried out getting the states and adding it into the if statement. It really didn’t do anything expect for disabling the script. This dash is meant to be used on the ground only not in the air too. The script is below.


Dash Script

-- UIS
-- !strict
local UIS = game:GetService("UserInputService")
-- Keys
local DKeyDown = false
local SKeyDown = false
local AKeyDown = false
local WKeyDown = false
-- Variables 
local Blocking = false
local camera = workspace.CurrentCamera

local Player = game.Players.LocalPlayer
local Char = Player.Character or Player.CharacterAdded:Wait()

while Char.Parent == nil do
	Char.AncestryChanged:wait()
end

local Falling = false
-- Anims
local HumRP = Char:WaitForChild("HumanoidRootPart")
local Hum = Char:WaitForChild("Humanoid")
local RollFrontAnim = Hum:LoadAnimation(script:WaitForChild("RollFront"))
local BackRollAnim = Hum:LoadAnimation(script:WaitForChild("BackRoll"))
local LeftRollAnim = Hum:LoadAnimation(script:WaitForChild("RightRoll"))
local RightRollAnim = Hum:LoadAnimation(script:WaitForChild("LeftRoll"))
-- Debounce
local DashDebounce = false
local DashingDebounce = false
local CanDoAnything = true
local d = script.Dash
local d2 = script.Dash
local d3 = script.Parent:WaitForChild("DashL")

-- Main Scripting
UIS.InputBegan:Connect(function(Input,IsTyping)
	if IsTyping then return end
	if Char:FindFirstChild("PBSTUN") then return end

	if Char:FindFirstChild("noJump") then return end
	if CanDoAnything == true then
		if Input.UserInputType == Enum.UserInputType.MouseButton1 then

		elseif Input.KeyCode == Enum.KeyCode.Q then
			if DashDebounce == false and Char:FindFirstChild("Disabled") == nil then
				
				DashDebounce = true
				CanDoAnything = false
				delay(0.3,function()
					CanDoAnything = true
				end)
				delay(2.5,function()
					DashDebounce = false
				end)
				if WKeyDown then
					Hum.JumpHeight = 0
					RollFrontAnim:Play()
					DashingDebounce = true
					d:Play()

					delay(0.25,function()
						DashingDebounce = false
						Hum.JumpHeight = 7.2
					end)

					repeat

						HumRP.Velocity = HumRP.CFrame.lookVector * 130 /1.5
						wait(0.1)
					until DashingDebounce == false
				elseif SKeyDown then
					Hum.JumpHeight = 0
					DashingDebounce = true
					BackRollAnim:Play()
					d:Play()
					
					delay(0.25,function()
						DashingDebounce = false
						Hum.JumpHeight = 7.2
					end)

					repeat

						HumRP.Velocity = HumRP.CFrame.lookVector * -130 /1.5
						wait(0.1)
					until DashingDebounce == false
				elseif DKeyDown then
					Hum.JumpHeight = 0
					DashingDebounce = true

					LeftRollAnim:Play()
					d2:Play()

					delay(0.25,function()
						DashingDebounce = false
						Hum.JumpHeight = 7.2
					end)

					repeat

						HumRP.Velocity = HumRP.CFrame.rightVector * 145 /1.5
						wait(0.11)
					until DashingDebounce == false
				elseif AKeyDown then
					Hum.JumpHeight = 0
					DashingDebounce = true
					d2:Play()

					RightRollAnim:Play()


					delay(0.25,function()
						DashingDebounce = false
						Hum.JumpHeight = 7.2
					end)

					repeat

						HumRP.Velocity = HumRP.CFrame.rightVector * -145 /1.5
						wait(0.11)
					until DashingDebounce == false
				end	
			end	


		end
	end
end)

local RunService = game:GetService("RunService")

RunService.RenderStepped:Connect(function()
	local Player = game.Players.LocalPlayer
	local Char = Player.Character
	local Hum = Char:FindFirstChild("Humanoid")

	if UIS:IsKeyDown(Enum.KeyCode.W)  then
		WKeyDown = true
	else
		WKeyDown = false
	end
	if UIS:IsKeyDown(Enum.KeyCode.A)  then
		AKeyDown = true
	else
		AKeyDown = false
	end
	if UIS:IsKeyDown(Enum.KeyCode.S) then
		SKeyDown = true
	else 
		SKeyDown = false
	end
	if UIS:IsKeyDown(Enum.KeyCode.D) then
		DKeyDown = true
	else 
		DKeyDown = false
	end


end)



1 Like

i didn’t try it but can you maybe try this i changed some thing there and there
the changed code block is

UIS.InputBegan:Connect(function(Input, IsTyping)
    if IsTyping then return end
    if Char:FindFirstChild("PBSTUN") then return end
    if Char:FindFirstChild("noJump") then return end
    if CanDoAnything == true and Hum.FloorMaterial ~= Enum.Material.Air then
        if Input.UserInputType == Enum.UserInputType.MouseButton1 then

        elseif Input.KeyCode == Enum.KeyCode.Q then
            if DashDebounce == false and Char:FindFirstChild("Disabled") == nil then
                DashDebounce = true
                CanDoAnything = false
                delay(0.3,function()
                    CanDoAnything = true
                end)
                delay(2.5,function()
                    DashDebounce = false
                end)
                if WKeyDown then
                    Hum.JumpHeight = 0
                    RollFrontAnim:Play()
                    DashingDebounce = true
                    d:Play()
                    delay(0.25,function()
                        DashingDebounce = false
                        Hum.JumpHeight = 7.2
                    end)
                    repeat
                        HumRP.Velocity = HumRP.CFrame.lookVector * 130 / 1.5
                        wait(0.1)
                    until DashingDebounce == false
                elseif SKeyDown then
                    Hum.JumpHeight = 0
                    DashingDebounce = true
                    BackRollAnim:Play()
                    d:Play()
                    delay(0.25,function()
                        DashingDebounce = false
                        Hum.JumpHeight = 7.2
                    end)
                    repeat
                        HumRP.Velocity = HumRP.CFrame.lookVector * -130 / 1.5
                        wait(0.1)
                    until DashingDebounce == false
                elseif DKeyDown then
                    Hum.JumpHeight = 0
                    DashingDebounce = true
                    LeftRollAnim:Play()
                    d2:Play()
                    delay(0.25,function()
                        DashingDebounce = false
                        Hum.JumpHeight = 7.2
                    end)
                    repeat
                        HumRP.Velocity = HumRP.CFrame.rightVector * 145 / 1.5
                        wait(0.11)
                    until DashingDebounce == false
                elseif AKeyDown then
                    Hum.JumpHeight = 0
                    DashingDebounce = true
                    d2:Play()
                    RightRollAnim:Play()
                    delay(0.25,function()
                        DashingDebounce = false
                        Hum.JumpHeight = 7.2
                    end)
                    repeat
                        HumRP.Velocity = HumRP.CFrame.rightVector * -145 / 1.5
                        wait(0.11)
                    until DashingDebounce == false
                end	
            end	
        end
    end
end)

-- UIS
-- !strict
local UIS = game:GetService("UserInputService")
-- Keys
local DKeyDown = false
local SKeyDown = false
local AKeyDown = false
local WKeyDown = false
-- Variables 
local Blocking = false
local camera = workspace.CurrentCamera

local Player = game.Players.LocalPlayer
local Char = Player.Character or Player.CharacterAdded:Wait()

while Char.Parent == nil do
	Char.AncestryChanged:Wait()
end

local Falling = false
-- Anims
local HumRP = Char:WaitForChild("HumanoidRootPart")
local Hum = Char:WaitForChild("Humanoid")
local RollFrontAnim = Hum:LoadAnimation(script:WaitForChild("RollFront"))
local BackRollAnim = Hum:LoadAnimation(script:WaitForChild("BackRoll"))
local LeftRollAnim = Hum:LoadAnimation(script:WaitForChild("RightRoll"))
local RightRollAnim = Hum:LoadAnimation(script:WaitForChild("LeftRoll"))
-- Debounce
local DashDebounce = false
local DashingDebounce = false
local CanDoAnything = true
local d = script.Dash
local d2 = script.Dash
local d3 = script.Parent:WaitForChild("DashL")

-- Main Scripting
UIS.InputBegan:Connect(function(Input, IsTyping)
	if IsTyping then return end
	if Char:FindFirstChild("PBSTUN") then return end
	if Char:FindFirstChild("noJump") then return end
	if CanDoAnything == true and Hum.FloorMaterial ~= Enum.Material.Air then
		if Input.UserInputType == Enum.UserInputType.MouseButton1 then

		elseif Input.KeyCode == Enum.KeyCode.Q then
			if DashDebounce == false and Char:FindFirstChild("Disabled") == nil then
				DashDebounce = true
				CanDoAnything = false
				delay(0.3,function()
					CanDoAnything = true
				end)
				delay(2.5,function()
					DashDebounce = false
				end)
				if WKeyDown then
					Hum.JumpHeight = 0
					RollFrontAnim:Play()
					DashingDebounce = true
					d:Play()
					delay(0.25,function()
						DashingDebounce = false
						Hum.JumpHeight = 7.2
					end)
					repeat
						HumRP.Velocity = HumRP.CFrame.lookVector * 130 / 1.5
						wait(0.1)
					until DashingDebounce == false
				elseif SKeyDown then
					Hum.JumpHeight = 0
					DashingDebounce = true
					BackRollAnim:Play()
					d:Play()
					delay(0.25,function()
						DashingDebounce = false
						Hum.JumpHeight = 7.2
					end)
					repeat
						HumRP.Velocity = HumRP.CFrame.lookVector * -130 / 1.5
						wait(0.1)
					until DashingDebounce == false
				elseif DKeyDown then
					Hum.JumpHeight = 0
					DashingDebounce = true
					LeftRollAnim:Play()
					d2:Play()
					delay(0.25,function()
						DashingDebounce = false
						Hum.JumpHeight = 7.2
					end)
					repeat
						HumRP.Velocity = HumRP.CFrame.rightVector * 145 / 1.5
						wait(0.11)
					until DashingDebounce == false
				elseif AKeyDown then
					Hum.JumpHeight = 0
					DashingDebounce = true
					d2:Play()
					RightRollAnim:Play()
					delay(0.25,function()
						DashingDebounce = false
						Hum.JumpHeight = 7.2
					end)
					repeat
						HumRP.Velocity = HumRP.CFrame.rightVector * -145 / 1.5
						wait(0.11)
					until DashingDebounce == false
				end	
			end	
		end
	end
end)

local RunService = game:GetService("RunService")

RunService.RenderStepped:Connect(function()
	local Player = game.Players.LocalPlayer
	local Char = Player.Character
	local Hum = Char:FindFirstChild("Humanoid")

	if UIS:IsKeyDown(Enum.KeyCode.W) then
		WKeyDown = true
	else
		WKeyDown = false
	end
	if UIS:IsKeyDown(Enum.KeyCode.A) then
		AKeyDown = true
	else
		AKeyDown = false
	end
	if UIS:IsKeyDown(Enum.KeyCode.S) then
		SKeyDown = true
	else 
		SKeyDown = false
	end
	if UIS:IsKeyDown(Enum.KeyCode.D) then
		DKeyDown = true
	else 
		DKeyDown = false
	end
end)
2 Likes

This actually worked thank you!

1 Like

no problem!!! if you have any more problems i’m happy to help!!

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