Animation Events and Client to Server Communication Problems

I’m trying to make a combat system while making sure my code is (mostly) secure. I want to handle debounce and hitbox information using animation events both on the client and the server. However I’m not sure how to make proper sanity checks to make sure the right animation event information is being sent, since my debounce and hitbox information is dependent on the animation event.

Thought about using GetPlayingAnimationTracks() but it seems like the server can’t actually detect this information?

image

Any help or insight would be appreciated, code below

function CombatSystem.ClientAttack(Data)

	if Data.Debounce then return end
	print(Data)
	Data.Debounce = true

	Data.NewCombo = tick()

	local lastAttack 
	
	if (Data.NewCombo - Data.LastCombo > 1.25) then
		Data.Combo = 1
		print("reset")
	end Data.LastCombo = Data.NewCombo

	
	local Character = Data.Character

	for _, animation in ipairs(Character.Humanoid.Animator:GetPlayingAnimationTracks()) do

		animation:Stop()

	end

	if Character.Humanoid.FloorMaterial ~= Enum.Material.Air then

		Data.Animations["Attack_Ground_".. Data.Combo]:Play(0)

	end
	
	print(Data.Character.Humanoid:GetPlayingAnimationTracks())
	
	Data.Animations["Attack_Ground_".. Data.Combo]:GetMarkerReachedSignal("HitboxStart"):Once(function()
		local sData = {Character = Data.Character, Combo = Data.Combo, Debounce = Data.Debounce}
		CombatRemote:FireServer(sData)
	end)
	
	-- if attack hits then cancel early and increase combo (test)	
	if true then

		Data.Animations["Attack_Ground_".. Data.Combo]:GetMarkerReachedSignal("HitboxEnd"):Once(function()

			if Data.Debounce then

				Data.Combo = CombatSystem.IncreaseCombo(Data.Combo)	
				Data.Debounce = false

			end	
		end)
		-- if attack misses then dont increase combo. debounce resets a the end of the animation.	
	else

		Data.Animations["Attack_Ground_".. Data.Combo].Stopped:Once(function()

			if Data.Debounce then 

				Data.Combo = 1
				Data.Debounce = false

			end
		end)
	end

end
function CombatSystem.ServerAttack(ClientData, ServerData)
	
	if ServerData.Debounce then return end

	ServerData.Debounce = true

	ServerData.NewCombo = tick()
	
	local lastAttack 
	if (ServerData.NewCombo - ServerData.LastCombo > 1.25) then
		ServerData.Combo = 1
		print("reset")
	end ServerData.LastCombo = ServerData.NewCombo
	
	-- testing for cancelling 
	if ClientData.Combo ~= ServerData.Combo then
		print("mismatch")
	end
	
	-- if attack hits then cancel early and increase combo  (none of this runs)
	if true then
       -- specifically this function doesn't run. I'm not sure how to check this on the server)
		ServerData.Animations["Attack_Ground_".. ServerData.Combo]:GetMarkerReachedSignal("HitboxEnd"):Once(function()
	
			if ServerData.Debounce then

				ServerData.Combo = CombatSystem.IncreaseCombo(ServerData.Combo)	
				ServerData.Debounce = false


			end	
		end)
		-- if attack misses then dont increase combo. debounce resets a the end of the animation.	
	else

		ServerData.Animations["Attack_Ground_".. ServerData.Combo].Stopped:Once(function()

			if ServerData.Debounce then 

				ServerData.Combo = 1
				ServerData.Debounce = false

			end
		end)
	end
	
	print(ServerData)
	
	return ServerData
	
end