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

How can I get this animation to play when I click?

Asked by 3 years ago

Here's my script:

local Mouse = game.Players.LocalPlayer:GetMouse()
local anime = script.Animation

Mouse.Button1Down:Connect(function()
    print("IT WORKED")
    anime:Play()
end)

It worked until I added the animation:Play()

0
You need to load the animation to the Animator (character.Humanoid.Animator) not the HUMANOID because that is deprecated. And then you have to make the loaded one like this local thing = humanoid.Animator:LoadAnimation(anime) and then you can do thing:Play() kepiblop 124 — 3y

2 answers

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

You gotta load the animation in the humanoid.

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local anime = humanoid:LoadAnimation(script.Animation)


anime:Play()
0
It doesn't work, I keep getting this error: LoadAnimation requires an Animation object surviarlTheJefkillre 55 — 3y
0
Oh oops, I meant script.Animation not script.Parent LeedleLeeRocket 1257 — 3y
0
That didnt work either It just says: Animation is not a valid member of LocalScript "Workspace.(My name).LocalScript" surviarlTheJefkillre 55 — 3y
0
It probably didn't load yet. try script:WaitForChild("Animation") LeedleLeeRocket 1257 — 3y
View all comments (3 more)
0
Its still doesnt work but we are getting somewhere because I dont get the error until I click. Right now the error i get is:Play is not a valid member of Animation "Workspace.Paczki_TCBC.LocalScript.Animation" surviarlTheJefkillre 55 — 3y
0
welp im all out of ideas LeedleLeeRocket 1257 — 3y
0
its ok surviarlTheJefkillre 55 — 3y
Ad
Log in to vote
0
Answered by
rkdss 25
3 years ago

use :LoadAnimation([Animation]) and put script to StarterCharacterScripts

local Mouse = game.Players.LocalPlayer:GetMouse()
local anime = script.Animation

Mouse.Button1Down:Connect(function()
    script.Parent.Humanoid:LoadAnimation(anime):Play()
end)

0
humanoid:LoadAnimation() is deprecated so its not reccomended, you should try humanoid.Animator:LoadAnimation() kepiblop 124 — 3y

Answer this question