ik my code is awful to read, I wa sjust wondering how do I make it so that if a player doesn’t attack after a certain amount of seconds the combat counter returns to 1 if you know what I mean
local uis = game:GetService("UserInputService")
local rs = game:GetService("ReplicatedStorage")
local player = game:GetService("Players").LocalPlayer
local chr = player.Character
local leaderstats = player:WaitForChild("leaderstats")
local race = leaderstats:WaitForChild("race")
local DashAttackEvent = rs:WaitForChild("DashAttackEvent")
local hum = chr:WaitForChild("Humanoid")
local stunnedevent = rs:WaitForChild("StunnedEvent")
local ListOfWeapons = {
"BasicSword",
"RengokuSword",
"PlaceHolder1",
}
local anim = game:GetService("ReplicatedFirst").Animations.RegularANIMS:WaitForChild("RunAnims")
local runAnim = hum:LoadAnimation(anim)
local module = require(rs:WaitForChild("Modules").CombatSystemModule)
local CombatNum = 1
local debounce = false
local candashattack = true
local DefaultFOV = 70
local lastTime = tick()
uis.InputBegan:Connect(function(input,e)
if e then return end
if input.UserInputType == Enum.UserInputType.MouseButton1 then
for i,v in player.Character:GetChildren() do
if table.find(ListOfWeapons, v.Name) and v:IsA("MeshPart") and debounce == false and chr:GetAttribute("isDashing") == false and chr:GetAttribute("Stunned") == false and chr:GetAttribute("IsBlocking") == false and chr:GetAttribute("IsAttacking") == false and chr:GetAttribute("Parried") == false then
debounce = true-- assuming this is the problem, as it may of let other MeshParts through
module.CombatSystem(player, CombatNum)
CombatNum += 1
if CombatNum > 4 then
CombatNum = 1
end
if chr:GetAttribute("IsRunning") == true then
hum.WalkSpeed = 16
runAnim:Stop()
local properties = {FieldOfView = DefaultFOV}
local Info = TweenInfo.new(0.5,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0.1)
local T = game:GetService("TweenService"):Create(game.Workspace.CurrentCamera,Info,properties)
T:Play()
end
stunnedevent:FireServer()
task.wait(0.2)
task.wait(0.3)
debounce = false
return
end
end
end
if input.KeyCode == Enum.KeyCode.R then
if race.Value ~= "Demon" and candashattack == true and chr:GetAttribute("Stunned") == false and chr:GetAttribute("IsBlocking") == false and chr:GetAttribute("IsAttacking") == false and chr:GetAttribute("SwordEquip") == true then
candashattack = false
local speed = hum.WalkSpeed
hum.WalkSpeed = 3
local dashattackanim = game:GetService("ReplicatedFirst").Animations.DashAttackAim
local dashattacktrack = hum:LoadAnimation(dashattackanim)
dashattacktrack:Play()
dashattacktrack:GetMarkerReachedSignal("SpawnHitBoxEvent"):connect(function()
DashAttackEvent:FireServer()
end)
hum.WalkSpeed = speed
task.wait(3)
candashattack = true
end
end
if input.UserInputType == Enum.UserInputType.MouseButton1 then
if debounce == false and chr:GetAttribute("isDashing") == false and chr:GetAttribute("Stunned") == false and chr:GetAttribute("IsBlocking") == false and chr:GetAttribute("IsAttacking") == false and chr:GetAttribute("Parried") == false and chr:GetAttribute("FistAcivated") == true then
debounce = true-- a
print("works")
module.FistSystem(player, CombatNum)
CombatNum += 1
if CombatNum > 5 then
CombatNum = 1
end
if chr:GetAttribute("IsRunning") == true then
hum.WalkSpeed = 16
runAnim:Stop()
local properties = {FieldOfView = DefaultFOV}
local Info = TweenInfo.new(0.5,Enum.EasingStyle.Sine,Enum.EasingDirection.InOut,0.1)
local T = game:GetService("TweenService"):Create(game.Workspace.CurrentCamera,Info,properties)
T:Play()
end
stunnedevent:FireServer()
task.wait(0.2)
task.wait(0.3)
debounce = false
end
end
end)