Animation only works once

You can write your topic however you want, but you need to answer these questions:

  1. I Want to have a working jumpscare animation, the first time getting killed it works perfectly however after that the animation doesnt play, i have the jumpscare on action, ive tried to load the animation in the player dying function and have tried to create a new instance of the animation

here is the script

    game.Players.PlayerAdded:Connect(function(Player)
local Camera = workspace.CurrentCamera	
local character = Player.Character or Player.CharacterAdded:Wait()
wait(1)

Player.Character:WaitForChild("Humanoid").Died:Connect(function(player)
	local attack = Instance.new("Animation")
	attack.AnimationId = "rbxassetid://13819115010"
	local attackAnim = script.Parent.Animator:LoadAnimation(attack)

	attackAnim:Play()

	workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
end)

end)

1 Like

Hi Carpet,

This is because you’re only connecting to the first instance of the player dying. Specifically, I’m referring to this line:

local character = Player.Character or Player.CharacterAdded:Wait()

In this case, your script only responds to the first character that a player has. Consider using Player.CharacterAdded to connect to each character instance, and run it as needed.

Ex:

game.Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(character)
        --TODO: Load animation inside of here
    end)
end)

Hope this helps!

Best,
Speedy

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.