Error: " 09:22:22.639 - ServerScriptService.Script:5: attempt to index nil with 'LoadAnimation'"
local uip = game:GetService("UserInputService") local char = script.Parent local human = char:WaitForChild("Humanoid", 1) local anim = char:WaitForChild("Lookatwrist", 1) local animtrack = human:LoadAnimation(anim) uip.InputBegan:Connect(function(input) if input.KeyCode == Enum.KeyCode.E then animtrack:Play() print("played") end end)
i am trying to make it play a animation when you press e but it wont work please help
You need to put this code into a LocalScript in StarterCharacterScripts or StarterPlayerScripts as UserInputService works only on the client.
You can then set:
char = game.Players.LocalPlayer.Character
Your char variable wasn't actually referencing a character, so there was no humanoid to load the script into as a result, causing the error.