local UserInputService = game:GetService("UserInputService") local Animation = script.Parent
UserInputService.InputBegan:Connect(function(InputObject) if InputObject.UserInputType == Enum.UserInputType.MouseButton1 then local Player = game.Players.LocalPlayer local Character = Player.Character local Humanoid = Character:WaitForChild("Humanoid")
local Anim = Humanoid:LoadAnimation (Animation) Anim:Play() end
end)
FYI the animation is under the local script
I decided to copy your code and put an Animation object in StarterPack then put a LocalScript inside the Animation object, after doing this I pasted your code into the local script and everything worked fine, animation played, no errors. I recommend you check if the Animation object you have has an ID in it if not then that may be the problem. Otherwise the animation provided is different from the character type you have in your game, for instance your game's character type is r6 but the animation is for r15 then that animation will not work for your game. Also make sure the local script you have is under StarterPack, StarterCharacterScripts or StarterPlayerScripts. Here's your script I copied if wondering.
local UserInputService = game:GetService("UserInputService") local Animation = script.Parent UserInputService.InputBegan:Connect(function(InputObject) if InputObject.UserInputType == Enum.UserInputType.MouseButton1 then local Player = game.Players.LocalPlayer local Character = Player.Character local Humanoid = Character:WaitForChild("Humanoid") local AnimationTrack = Humanoid:LoadAnimation(Animation) AnimationTrack:Play() end end)