Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Animation does not play after respawn?

Asked by 6 years ago

I am currently messing around with animations and I'm running into an issue I can't seem to get around...

The animation plays correctly the first time when the character has existed prior however, when the character dies and I want the animation the play once again, it does not happen. Does anyone have any suggestions to what I could try?

Thanks!

local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.Character:wait()

local animation = character.Humanoid:WaitForChild("holdAnimation")
local playHoldAnimation = character.Humanoid:LoadAnimation(animation)

redGun = player.Backpack:WaitForChild("Red Laser Gun")
blueGun = player.Backpack:WaitForChild("Blue Laser Gun")

redGun.Equipped:connect(function()
    print("fired")
    playHoldAnimation:Play()
    playHoldAnimation.KeyframeReached:connect(function(keyFrameName)
        if keyFrameName == "here" then
            playHoldAnimation.TimePosition = .25
        end
    end)

end)

redGun.Unequipped:connect(function()

    playHoldAnimation:Stop()

end)
0
It might not work because you change character, try to put the loadanimation inside the equipped event (the char too) User#20388 0 — 6y
0
Unfortunately that did not work, but thank you for the suggestion! :) Platinum19126 9 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

I just placed the code in another LocalScript and it seems to be working. This was odd. Thanks though!

Ad

Answer this question