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.