I have a combat script that, with each m1, increases the combo count.
This script also uses a :GetMarkerReachedSignal() event in order to let the script know when to detect a hit during an animation.
Here is the script:
local m1Anim : AnimationTrack = CombatModule.PlayAnimation(tostring(combatinfo.Weapon.. combatinfo.Combo))
m1Anim:GetMarkerReachedSignal("hit"):Once(function()
local detectedHit, Enemies = CombatModule.HitboxDetection(combatinfo.Character)
if detectedHit and Enemies then
CombatEvent:FireServer("ServerCombat", "OnHit", Enemies, combatinfo)
end
end)
combatinfo.LastM1 = os.clock()
print(combatinfo.Combo)
character:SetAttribute("Action", "M1")
character:SetAttribute("M1", true)
if combatinfo.Combo >= 5 then
combatinfo.Combo = 1
task.delay(combatinfo.ComboCooldown, function()
character:SetAttribute("Action", "None")
character:SetAttribute("M1", false)
end)
else
combatinfo.Combo += 1
task.delay(combatinfo.M1CD, function()
character:SetAttribute("Action", "None")
character:SetAttribute("M1", false)
end)
end
On the 5th m1, I want to knock back the enemy and ragdoll them (I already know how to do this), but the main issue is that every time I send the combo count from the client to the server, it’s always 1 ahead on the server because it increases the count before the :GetMarkerReachedSignal()
event fires.
For example, let’s say I currently just performed my 2nd m1. On the server, it registers as the 3rd m1 because again, the combo increases before the animation event fires. Is there any way I can yield the script or do something about this to wait to increase the combo count? Help is much appreciated!