Every time GetMarkerReachedSignal() used, it connects exponentially more

I have eight markers in my sliding animation to trigger a foot trail effect, however every time it connects it stacks over and over infinitely


(Every time the effect runs through, it outputs the floor material.)
Here’s a snippet of my code:

	local marker3 = Swing3:GetMarkerReachedSignal("EffectEvent2")
	Swing3:Play()
	local function feettrail()
		local s = raypart(RootPart)
		if s~= nil then
		Fire:FireServer("Elliptis","FootTrail",LeftLeg.CFrame,s.Material,s.BrickColor)
		Fire:FireServer("Elliptis","FootTrail",RightLeg.CFrame,s.Material,s.BrickColor)
		end
	end
	marker3:Connect(feettrail)

You only need to connect this one time.

Swing3:Play()
marker3:Connect(feettrail)

Every time you play, you’re connecting again.

1 Like

No change, continues to spam connect.

You need to split this into two scripts.

local marker3 = Swing3:GetMarkerReachedSignal("EffectEvent2")
	local function feettrail()
		local s = raypart(RootPart)
		if s~= nil then
		Fire:FireServer("Elliptis","FootTrail",LeftLeg.CFrame,s.Material,s.BrickColor)
		Fire:FireServer("Elliptis","FootTrail",RightLeg.CFrame,s.Material,s.BrickColor)
		end
	end
	marker3:Connect(feettrail)

Only run that once.

Swing3:Play()

Run that whenever you play the animation.

I think it’d probably be more helpful to show more of your code, especially so it can be seen how this code is getting ran.

Realistically, you only need to call LoadAnimation once and set up your MarkerReached connections one time, so the only thing you’re doing upon reaching this sequence in an attack animation cycle is playing the animation, not also doing connections.

Furthermore, you don’t ever disconnect your connections, so understandably whenever this chunk is ran, it just keeps connecting more events.

1 Like

Honestly I completely forgot about disconnecting my connections, thanks for the reminder it worked.