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

How to fix Animations after dying?

Asked by 5 years ago
Edited 5 years ago

So I have some code for my animation, whenever someone fires a UserInput it will then play the animation. Here's the code:

--These are the variables for the animation
local Player = game.Players:WaitForChild("LocalPlayer")
local character = Player.Character or Player.CharacterAdded:wait()
local BlockAnimation = game.ReplicatedStorage.Animations:WaitForChild("BlockAnimation")
local Animation = character:WaitForChild("Humanoid"):LoadAnimation(BlockAnimation)
--This is the userinputservice that when F is pressed it will play the animation.
game:GetService("UserInputService").InputBegan:Connect(function(KeyDown, gameProcessed)
    if not gameProcessed then
        if KeyDown.KeyCode == Enum.KeyCode.F then
            Animation:Play()
        end
    end
end)

I do have a inputended etc, but whenever I reset my character. Or I die whenever I press F my animation won't play. So I'm wondering if this is just like some problem with the actual Character object respawning.. do I have to wait for it or something?

0
where are the location of the script? herrtt 387 — 5y
0
Starter Player Scripts and sup hertt hru User#21998 0 — 5y

1 answer

Log in to vote
1
Answered by
CPF2 406 Moderation Voter
5 years ago

put the script in StarterPack, this means that it will be re-added every time they respawn, fixing your problem

0
I was able to add them in StarterCharacterScripts, and it worked fine. But this can also work too, so I'll accept your answer :D User#21998 0 — 5y
Ad

Answer this question