#GetMarkerReachedSignal stacking events in function

1 messages · Page 1 of 1 (latest)

maiden knot
#

I am using GetMarkerReachedSignal to print "hit" every time an animation gets to a certain point, but every time I use it, it stacks and prints a second time

Example: I play the animation once and it only prints once, then I play the animation a second time and it prints twice

The code I am using:

swing4:GetMarkerReachedSignal("EventName"):Connect(function()
game.ReplicatedStorage.Remote.Server:FireServer("M1", 5 )

                print("hit")
            end)
slow trellis
#

you can try adding a debounce like it checks if the debounce is true. And if it is true then it does nothing.

maiden knot
#

I have a debounce in place, the problem is when I trigger it the first time, it only prints once, but every subsequent trigger causes it to play an extra time, even though I only triggered it once

fiery archBOT
#

studio** You are now Level 1! **studio

maiden knot
#

It prints once, then twice, then 3 times etc.

#

When I only want it to trigger once when i trigger it

barren narwhal
#

Maybe u create a new event every time you want to play the animation. Try the GetMarkerReachedSignal outside of a function or event (make sure it has no end below it if you know what i mean) or :Disconnect() the event.

Here is how u can disconnect the event if you want to do that:

local event
event = swing4:GetMarkerReachedSignal("EventName"):Connect(function()
game.ReplicatedStorage.Remote.Server:FireServer("M1", 5 )

  print("hit")

event:Disconnect()
end)

proven drum
coarse canyon
#

you're probably connecting the event more than once. very common beginner mistake

maiden knot
#

disconnect doesnt fix the problem

#

it still plays an extra time every time it runs

#

wait

#

that seemed to have fixed it

#

ty