I’m trying to figure out why my animation event is firing multiple times in one playthrough of an animation. I’d like to have it so when the player’s special move is enabled, the ability/function is run once the player hits another player. For some reason, though, my ‘Special’ boolean value returns nil after first printing as true when I print it inside the marker reached signal function. For some reason, the get marker reached signal seems to run multiple times.
Code:
function module.Swing(AnimTable, Tool, Damage, UserHumanoid, Hitbox, Special)
local Handle = Tool:FindFirstChild("Handle")
if Hitbox then
local ChosenAnim = #AnimTable > 1 and AnimTable[math.random(1, #AnimTable)] or AnimTable[1]
local TouchConnection
ChosenAnim:Play()
print(Special)
ChosenAnim:GetMarkerReachedSignal("EnableHit"):Connect(function()
print(Special)
Hitbox:HitStart()
TouchConnection = Hitbox.OnHit:Connect(function(hit, Hum)
print(Special)
if Special == true then
print("YEE")
WeaponSpecials[Tool.Name](Hum)
end
Hum:TakeDamage(Damage)
end)
end)
ChosenAnim.Stopped:Connect(function()
Hitbox:HitStop()
end)
end
end