#Animation not stopping after I tell it to using GetMarketReachedSignal, only stops at the end

1 messages · Page 1 of 1 (latest)

terse abyss
#
ChargeReleasedEvent.OnServerEvent:Connect(function(plr) -- this happens on user inputservice.inputended

    IsCharging[plr.UserId] = false
    task.delay(3, function()
    IsCharging[plr.UserId] = true
    end)
end)

if skill == "ChargedSmash" then -- OnInputBegan
        if PlayerCooldowns[plr.UserId][skill] then return end -- check if ChargedSmash is on cooldown
        PlayerCooldowns[plr.UserId][skill] = true
        task.delay(10, function()
            PlayerCooldowns[plr.UserId][skill] = nil
        end)
    
    if PlayerCooldowns[plr.UserId].SkillInAction then return end
    PlayerCooldowns[plr.UserId].SkillInAction = true -- code is cooked, skills wont player after one is finished
        
        local Charge = rs['Animations']["GreenHeroAnims"].ChargeSmash
        local Smash = rs['Animations']["GreenHeroAnims"].ChargeSmashRelease
        local ChargeTrack = hum.Animator:LoadAnimation(Charge)
        local SmashTrack = hum.Animator:LoadAnimation(Smash)
        local ChargeAmount = 0
        IsCharging[plr.UserId] = true
        
        ChargeTrack:GetMarkerReachedSignal("Charge1"):Connect(function()
            ChargeAmount += 1
            print("1")
            if not IsCharging[plr.UserId] then
                ChargeTrack:Stop()
                SmashTrack:Play()    
            end
        end)
        
        ChargeTrack:GetMarkerReachedSignal("Charge2"):Connect(function()
            ChargeAmount += 1
            print("2")
            if not IsCharging[plr.UserId] then
                ChargeTrack:Stop()
                SmashTrack:Play()
            end
        end)
        
        ChargeTrack:GetMarkerReachedSignal("Charge3"):Connect(function()
            ChargeAmount += 1
            print("3")
            IsCharging[plr.UserId] = true -- do it for the player who doesn't want to let go, stubborn player...
            ChargeTrack:Stop()
            SmashTrack:Play()
        end)
        
        ChargeTrack:Play() -- start the charging```
#

Please note the if skill == ChargedSmash is in another event connected function

#

To sum the issue up, the animation keeps playing until the third marker (or the end of the anim, idk which) and only then plays the smash animation. I want to make it so if the player releases early, the smash attack occurs, sooner, specifically checking if the skill key is still being held at each marker, and if not, the charge should stop and the smash should start

thorny scaffold
terse abyss
#

basically it starts the animation and then gets the animation events

#

and then checks to see if the button has been released by the player yet through the ischarging table and the player's id

thorny scaffold
#

Are these GetMarkerReachedSignalEvents firing? You get all the print() functions?

terse abyss
#

yes they all print

#

up to 3

thorny scaffold
#

Have you tried to use Animation:Destroy() after the :Stop() method?

terse abyss
#

i have not, but if destroy it should i use a clone instance instead?

#

dumb question obviously i should

thorny scaffold
#

yeah, you should

#

Later on I'll recommend some little optimization

terse abyss
#

nah didnt work

#

same issue

#

prints all 3

thorny scaffold
#

Hmm

#

Probably some animation priority issue?

terse abyss
#

maybe

fair acorn
#

Animation Priority is Different from Animation Properties.

terse abyss
#

well the aniim plays

#

both of them

thorny scaffold
thorny scaffold
terse abyss
#

chat gpt says that if i stop the animation in the market it won't work, but i dont know where else i could put them

smoky shuttleBOT
#

studio** You are now Level 9! **studio

fair acorn
# terse abyss both of them

Cant you just detect on how long they've been holding it down for? or how long it has been playing rather than relying on animation signals?

#

Cause they only fire Once

terse abyss
#

like get key frame instead?

fair acorn
#

Nada,

#

How are you even handling this?

#

does it depend on how long a keypress has been made?

#

or depending on how long it has been on before being pressed again?

terse abyss
#

nah just uis input began ane ended

#

uis.InputBegan:Connect(function(input, isTyping) -- charge smash
if isTyping then return end
if input.KeyCode == Enum.KeyCode.Two then
event:FireServer("ChargedSmash")
end
end)

uis.InputEnded:Connect(function(input, isTyping) -- charge smash end
if isTyping then return end
if input.KeyCode == Enum.KeyCode.Two then
event:FireServer("ChargedSmashEnd")
end
end)

#

local script part^

thorny scaffold
#

I mean he was talking about the client tracking the time and sending it to the server @terse abyss

fair acorn
#

and use < & > instead of animation signals

terse abyss
#

sorry but im like a baby scripter how can i detect how long they've been holding for? os clock or tick()?

fair acorn
#

if i remember correctly, Animation signals only fire and doesnt wait unlike functions.

#

or anything that waits

terse abyss
#

would you mind scripting an example for me? I know that's asking a bit much but im lowk lost, im a visual learner ._.

fair acorn
#

i havent really done any os.clock or tick() scripts tbh 😭

#

ive been using while _ do

#

LOL

terse abyss
#

fair enough, maybe i can get chat gpt to give me and example then ill just make practice exercices from that

thorny scaffold
#

I'll write some example

local currentTime = tick()

-- An event here
local elapsed_Time = tick() - currentTime

fair acorn
#

but in all honesty, this isj ust my opinion, dont know about the others

#

theres probably hundreds of ways doing this

#

🤷‍♂️

#

all i can say is goodluck twin

terse abyss
#

thanks for the help anyway. better than no response

#

i at least have some idea now

thorny scaffold
#

@terse abyss The optimization stuff I was talking about:

Instead of asking your script to try to find an animation object in ReplicatedStorage everytime this events fires, store it outside the function scope. Doing that you can Load its clones and this will give you some small performance changes.

terse abyss
#

Is there a point to replicating if it if im not going to destroy it?

thorny scaffold
#

After it finishes you should destroy it

thorny scaffold
#

Same with connections

#

You need to disconnect them manually

fair acorn
#

"small performance changes"...

craggy sequoia
#

hey pookies

fair acorn
thorny scaffold
fair acorn
#

and also depends on the lazyness

thorny scaffold
#

@terse abyss

Or you either store a connection to disconnect manually later, or you can use the :Once() method, which will, as it says, run the function once and disconnect itself automatically

fair acorn
#

i think were getting a bit too off topic here mate

thorny scaffold
fair acorn
thorny scaffold
fair acorn
#

it only fires it ** ONCE **

thorny scaffold
fair acorn
#

yeah, but his issue is the animation is not stopping

thorny scaffold
#

You already gave him some light, bro, he's working on the problem by himself, I'm just giving some tips as long as he said he's a beginner on scripting

fair acorn
#

ah

thorny scaffold
#

And memory leaks are terrible

fair acorn
#

but overall these can be the possible issues:

  1. Animation signals were never met,

  2. Animation signals only runs once, never waiting for something else.

#

oh wait

#

i have a fix LOL

terse abyss
#

yeah its late for me and im too lazy to script rn, so ill test out the time that the player releases the key method and send that to the server tmr, and if that doesnt work ill try the 'At this keyframe, do this" method

fair acorn
#

alright

#

goodnight

#

i hope you can fix this!

terse abyss
#

thank you for the encouragement lol

thorny scaffold
#

So, just to finish, @terse abyss

Example of how you can store your connections:

-- Define it as a global variable, outside any function
local connections = {}

-- And when you need to add a connection inside a function you do that:
connections['someMarkerConnection'] = Animation:GetMarkerReachedSignal:Connect(function()

end)

-- After you finish with this connection
if connections'[someMarkerConnection'] then
connections['someMarkerConnection']:Disconnect()
connections['someMarkerConnection'] = nil
end

#

Gl with your game, bye

terse abyss
#

thx man

terse abyss
#

You guys wont believe how dumb i am. I binded the wrong event to the input ended on the local script

#

omg it worked, ALL I HAD TO DO WAS CHANGE ONE VARIABLE I HATE BEING A PLEB 😭