The title says everything you need to know. But in more detail, I’m playing an animation and I’m using a MarkerSignal to detect when the certain keyframe is reached, it works amazing, but for some reason it gets fired twice.
Code
local anim = animator:LoadAnimation(anim)
anim.Looped = true
anim:AdjustSpeed(0.5)
anim:Play(0.2)
savedTicks[plr.UserId] = tick()
local animConnection
animConnection = anim:GetMarkerReachedSignal('HitStone'):Connect(function()
mineLeftVal.Value -= 1
minTillD.Value = tostring(mineLeftVal.Value) .. ", " .. orgValMin
playSound(hitStone, miningWhichRock.Value)
guiText.Text = tostring(mineLeftVal.Value) .. "/" .. tostring(orgValMin) .. "⛏️"
local c = particle:Clone()
c.Parent = clickBox
task.wait(particleTimeOnHit)
c:Destroy()
if mineLeftVal.Value == 0 then
animConnection:Disconnect()
local increaseMoneyBuy = math.random(minMoney.Value, maxMoney.Value)
increaseMoney(numOfCones, increaseMoneyBuy, plr)
stopPlayer(plr)
MineRockEvent:FireClient(plr, "stopMining")
anim:Stop(0.2)
end
end)
MineRockEvent:FireClient(plr)
I’ve done some test’s, and the script isn’t getting fired twice, just the marker is.