Currently I want to do something such as Dashing in my game, with two different functionalities, dodging on the first press, and on the second press I want it actually do that dash (On top of that, if dodging on cd I want it to automatically go to dashing, but that’s probably a different topic.)
For this reason, I want to know how I’d be able to fix my script to do that, as I’m attempting to do a count method and it isn’t really working in the way that I want it to.
E.G
(Learned instead that the dash is delayed and then it resets.)
local TS = game:GetService("TweenService")
local DE = game:GetService("Debris")
local PLRS = game:GetService("Players")
local UIS = game:GetService("UserInputService")
local Player = PLRS.LocalPlayer
local Character = Player.Character
local Humanoid = Character:FindFirstChild("Humanoid")
local HumRP = Character:FindFirstChild("HumanoidRootPart")
local RS = game:GetService("RunService")
local CloseChar = 1000000
local CurrTime = 0
local PrevTime = 0
local Target = 0
local count = 0
local WIsHeld = false
local DIsHeld = false
local SIsHeld = false
local AIsHeld = false
local debounce = false
local debounce2 = false
local Blacklist = {}
UIS.InputBegan:Connect(function(Input, Proccessed)
if Proccessed then return end
if debounce == true then return end
if Input.KeyCode == Enum.KeyCode.Q then
count += 1
if debounce == false then
debounce = true
if count == 1 then
print(count)
count += 1
for i, char in pairs(workspace.PlayerHitboxes:GetChildren()) do
if char and char:FindFirstChildOfClass("ObjectValue") and char.Char.Value ~= Character then
local Char = char.Char.Value
local Ehrp = Char:FindFirstChild("HumanoidRootPart")
local mag = (Character.HumanoidRootPart.Position-Ehrp.Position).Magnitude
if mag < 5 then
script.Dodging:FireServer()
print(count)
end
task.wait(10)
debounce2 = false
end
end
end
if count == 2 then
print(count)
if WIsHeld == true then
end
if SIsHeld == true then
end
if AIsHeld == true then
end
if DIsHeld == true then
end
script.Dashin:FireServer()
task.wait(4)
debounce = false
count = 0
end
end
end
end)
RS.RenderStepped:Connect(function()
if UIS:IsKeyDown(Enum.KeyCode.W) then
WIsHeld = true
else
WIsHeld = false
end
if UIS:IsKeyDown(Enum.KeyCode.S) then
SIsHeld = true
else
SIsHeld = false
end
if UIS:IsKeyDown(Enum.KeyCode.D) then
DIsHeld = true
else
DIsHeld = false
end
if UIS:IsKeyDown(Enum.KeyCode.A) then
AIsHeld = true
else
AIsHeld = false
end
end)
If I could get some assistance, I would greatly apperciate it.