Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Can I have some help with UserInputService and Animations?

Asked by 3 years ago
Edited 3 years ago

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

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

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

local Track = Humanoid.Animator:LoadAnimation(Animation)

hope this helps

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. NotOreo9 8 — 3y
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. Finty_james 269 — 3y
Ad

Answer this question