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

How do I get my animation code to play instead of not working?

Asked by 7 years ago

For some odd reason the code that I use to play animations for my Player isn't working. Here is the script

01local Player = game.Players.LocalPlayer
02local Mouse = Player:GetMouse()
03 
04Mouse.KeyDown:connect(function(key)
05    key = key:lower()
06    if key == "g" then
07        local anim = Player.Character.Humanoid:LoadAnimation(script.Animation)
08    game:GetService("Chat"):Chat(Player.Character.Head, "BLESSED HAMMER!", "Blue")
09        local x = game.ReplicatedFirst.Hammer.Handle:Clone()
10        x.Parent = game.Workspace
11        x.Name = "NotIceHammer"    
12        x.Anchored = false
13        x.CanCollide = true x.CFrame=Player.Character.Head.CFrame*CFrame.new(0,6.5,4)*CFrame.Angles(0,math.pi/2,2*math.pi/9)
14        local pe = Instance.new("ParticleEmitter", x) --Make the Hammer look Blessful-ly
15        pe.Size = NumberSequence.new(0,2.62)
View all 42 lines...

The Animation Code used in this script is what I use for other scripts like this and they work just fine. I also have tried changing the Animation Priority to "Movement" and that didn't help either.

1 answer

Log in to vote
0
Answered by 7 years ago

You have to actually PLAY the animation

1local anim = Player.Character.Humanoid:LoadAnimation(script.Animation)

Instead of just making the animation a variable and not using it You have to play it like this

1local anim = Player.Character.Humanoid:LoadAnimation(script.Animation)
2anim:Play()

And if its a looped animation you stop it like this

1anim:Stop()
0
But I did...Look at line 37 and even though I don’t think it matters I also tried putting it right after LOCAL ANIM = Player.Character.Humanoid:LoadAnimation(script.Animation) awesomeestef1 -3 — 7y
0
Try putting some print() functions around and see if the event is actually being fired BerrySus 65 — 7y
Ad

Answer this question