Script completely breaks

I have a boolean value in my script and when i do the statements that check if its false that statements are the only ones that work and not the statements that check if its true

i was attempting to make a dash script pls can anyone find the solution to it

local UserInputService = game:GetService("UserInputService")
local Camera = game.Workspace.CurrentCamera

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Root:Part = Character:WaitForChild("HumanoidRootPart") or Character.PrimaryPart

local IsHoldingW = false
local IsHoldingA = false
local IsHoldingS = false
local IsHoldingD = false

local Debounce = false
local Repeats = 30
math.clamp(Repeats, 1, 30)

UserInputService.InputBegan:Connect(function(Input, gameProcessedEvent)
	if Debounce then
		return
	end
	Debounce = true
	if Debounce then
	if Input.KeyCode == Enum.KeyCode.W then
		IsHoldingW = true
		print(IsHoldingW)
	end
	if Input.KeyCode == Enum.KeyCode.A then
		IsHoldingA = true
	end
	if Input.KeyCode == Enum.KeyCode.S then
		IsHoldingS = true
	end
	if Input.KeyCode == Enum.KeyCode.D then
		IsHoldingD = true
	end
	if gameProcessedEvent then
		return
	end
	if Input.KeyCode == Enum.KeyCode.Q and IsHoldingW and not gameProcessedEvent then
			Root.AssemblyLinearVelocity = Root.CFrame.LookVector * 200
		end
	if Input.KeyCode == Enum.KeyCode.Q and IsHoldingA and not gameProcessedEvent then
			Root.AssemblyLinearVelocity = -Root.CFrame.RightVector * 200
		end
	if Input.KeyCode == Enum.KeyCode.Q and IsHoldingS and not gameProcessedEvent then
			Root.AssemblyLinearVelocity = -Root.CFrame.LookVector * 200
		end
	if Input.KeyCode == Enum.KeyCode.Q and IsHoldingD and not gameProcessedEvent then
			Root.AssemblyLinearVelocity = Root.CFrame.RightVector * 200
		end
	if Input.KeyCode == Enum.KeyCode.Q and not IsHoldingW and not IsHoldingA and not IsHoldingS and not IsHoldingD and not gameProcessedEvent then
		Root.AssemblyLinearVelocity = Camera.CFrame.LookVector * 200
		task.spawn(function()
		for i=1, Repeats do
		Root.CFrame = Root.CFrame:Lerp(CFrame.lookAt(Root.Position, Root.Position + Camera.CFrame.LookVector), 0.15)
		print(IsHoldingW, "success")
		task.wait(0.001)
				end
			end)
		end
	end
	task.wait(1)
		Debounce = false
end)

UserInputService.InputEnded:Connect(function(Input, gameProcessedEvent)
	if Input.KeyCode == Enum.KeyCode.W then
		IsHoldingW = false
	end
	if Input.KeyCode == Enum.KeyCode.A then
		IsHoldingA = false
	end
	if Input.KeyCode == Enum.KeyCode.S then
		IsHoldingS = false
	end
	if Input.KeyCode == Enum.KeyCode.D then
		IsHoldingD = false
	end
	if gameProcessedEvent then
		return
	end
end)

print(IsHoldingW)
2 Likes

Which bool is the problem you have a few

1 Like

all if statements that has not in it

all of my boolean values is the problem

Your math.clamp is doing nothing, you need to assign it to a variable
Your debounce is locking ALL input including your wasd down if statements
Also you’re repeating if statements when you could just combine already existing ones

1 Like

Put the movement direction checks before the dash ability debounce

2 Likes

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