local UserInputService = game:GetService(“UserInputService”)
local animationId = 15377435145
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local humanoid = character:WaitForChild(“Humanoid”)
local animationController = humanoid:WaitForChild(“Animator”) – Change “Animator” to the name of your AnimationController
local function playAnimation()
local animationTrack = humanoid:LoadAnimation(animationId)
animationTrack:Play()
end
character:WaitForChild("Humanoid").Died:Connect(function()
end)
humanoid.Died:Connect(function()
end)
UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if gameProcessedEvent then
return
end
if input.UserInputType == Enum.UserInputType.MouseButton1 then
playAnimation()
end
end)
end)
Add some debug statements and show us the output.
For example:
local UserInputService = game:GetService("UserInputService")
local animationId = 15377435145
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local humanoid = character:WaitForChild("Humanoid")
local animationController = humanoid:WaitForChild("Animator")
local function playAnimation()
print("Playing animation...")
local animationTrack = humanoid:LoadAnimation(animationId)
animationTrack:Play()
end
character:WaitForChild("Humanoid").Died:Connect(function()
print("Character died...")
end)
humanoid.Died:Connect(function()
print("Humanoid died...")
end)
UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if gameProcessedEvent then
return
end
if input.UserInputType == Enum.UserInputType.MouseButton1 then
print("Mouse button clicked...")
playAnimation()
end
end)
end)
end)
Currently you are loading your animation every single time you click, which is not good. Load the animation once and play that animation when you click.
Could you also please show us a screenshot of your character descendants in the workspace?