Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to fix Animations after dying?

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?

2 comments

0

where are the location of the script?

0

Starter Player Scripts and sup hertt hru

1 answer

✓ Accepted answer

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

1 comment

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

This discussion is preserved as it was. New answers, comments, and votes are closed.