Problem with passing arguments through BindableEvent

Hello, for some reason in my code for NPC combat, I try to pass 2 arguments through a BindableEvent: a Character, and a number called count, for the combo.

For some reason, when the Event is received it gets the Character, but sometimes the count is received as nil, even though I pass it through the BindableEvent, so for some reason nothing is being passed through.

Code for firing the remote:

			currTime = tick()
			local passedTime = currTime - prevTime
			if passedTime < 2 then
				count += 1

				if count > 4 then
					count = 1
				end
			else
				count = 1
			end
			
			M1Event:Fire(Character,count)

Code for receiving the remote (error occurs at the end):

M1Event.Event:Connect(function(Character: Model,count: number)
	local Humanoid = Character:FindFirstChildOfClass("Humanoid")
	local HumRP = Character:FindFirstChild("HumanoidRootPart")
	
	local AnimTable = {}

	local M1Anims = Character.M1Info.Anims
	table.insert(AnimTable,M1Anims.C1)
	table.insert(AnimTable,M1Anims.C2)
	table.insert(AnimTable,M1Anims.C3)
	table.insert(AnimTable,M1Anims.C4)
	
	local SwingAnimation = Humanoid.Animator:LoadAnimation(AnimTable[count])

It always works the first time, however.

Where is count defined? If it’s just as

local count
Add a

local count = 0

Also, another possibility is that there is no animTable with that index. And I’m pretty sure that the count can be on decimals too, so that’s also a possibility that errors the index thing

1 Like

It’s defined at the start of the script that has the code for firing the remote, initialised as 0. It works as normal in a LocalScript I made for Player use.

Something strange - for some reason when I put a print behind the AnimTable variable displaying the count, the script works, but there’s a different error telling me that I can’t concatenate a string, even though it prints as normal.