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

Animation does not play after respawn?

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)

2 comments

0

It might not work because you change character, try to put the loadanimation inside the equipped event (the char too)

0

Unfortunately that did not work, but thank you for the suggestion! :)

1 answer

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

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