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

Can I have some help with UserInputService and Animations?

Hi, so I am making a script that Utalises the UserInputService where when you click, an animation plays, but as you could guess it does not work. I have already looked through the roblox dev forum and to my knowledge I am doing everything correct; the animation priority is set to core, I am using a local script inside StarterCharacterScripts,and the code is riight (I have no errors in the output and no typos.) This is the code:

local service = game:GetService("UserInputService")

local Player = game.Players.LocalPlayer -- this also only works in LocalScripts local Character = Player.Character local Humanoid = Character:WaitForChild("Humanoid")

local Animation = Instance.new("Animation") Animation.AnimationId = "rbxassetid://6723323427"

local Track = Humanoid:LoadAnimation(Animation)

service.InputBegan:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseButton1 then print("button is down") Track:Play() end end)

May I have some help please.

1 answer

✓ Accepted answer

Humanoid:LoadAnimation() is deprecated. Try inserting an Animator into the Humanoid, then use

local Track = Humanoid.Animator:LoadAnimation(Animation)

hope this helps

2 comments

1

Thanks, along with this, I changed the avatar type in game from r6 to r15 and it works.I believe this is because i created the animation on an r15 rig.

1

I agree with Jasmin, because if you didnt know there is update. If you know, the animator can be create through Instance.new or by the animation editor.

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