Currently, I have a working system of combat, after a long long time of debugging and scripting evolution, but the biggest issue I’m dealing with is just one I can’t put my finger on.
See, everytime I have a return in my script, and the return is true, the script will never trigger again. I will show an example-
Combat.OnServerEvent:Connect(function(Player, Count)
-- removed Count = 0
local Character = Player.Character
local Humanoid = Character.Humanoid
local Humrp = Character.HumanoidRootPart
if Character:GetAttribute("IsBlocking") == true then
return
end
if Character.Effects:FindFirstChild("Stun") then
return
end
if Character:GetAttribute("Training") == true then
return
end
if not Character.Effects:FindFirstChild("Stun") then
Character:SetAttribute("CanAttack", true)
local Action, Length = CM.getAnimation(Humanoid, Count)
Action:Play()
CM.NormalCombat(Player, Character, 5, "Fists", Count, Length)
print(Count)
wait(Length)
--[[==[local KeyList = {}
for key, value in pairs(Key) do
table.insert(KeyList, key)
end
if not Character:FindFirstChild("Stun") then
if Humanoid:FindFirstChild("Clashing").Value == true then
print("It works")
print(Key[KeyList[math.random(#KeyList)])
Clashin:FireClient(Player, "Clashing")
CM.Clashing(Player, Character, Humrp, Key)
end
end
]]--
if Count < 4 then
Combat:FireClient(Player, false)
Character:SetAttribute("CanAttack", false)
else
Combat:FireClient(Player, true)
Character:SetAttribute("CanAttack", false)
--print(_G.CanAttack.Value)
end
else
Combat:FireClient(Player, false) --Resets their cooldowns
Character:SetAttribute("CanAttack", false)
--WERK:Disconnect()
end
end)
E.G
