Basically i rigged a model and animated into the animation editor but i have no idea how i would get the animation to play through a script. Im not requesting im just asking what would I use?
✓ ANSWER ACCEPTED
How would i play an animation through a script?
1 answer
✓ Accepted answer
-- Import animation
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/Asset?ID=144911345"
-- Local variables
local animTrack = nil
local canPlay = true
function playShockAnim(Source)
if canPlay then
local player = game.Players.LocalPlayer.Character
canPlay = false
animTrack = player.Humanoid:LoadAnimation(animation) -- Load animation into Humanoid
animTrack.KeyframeReached:connect(function(keyframeName) -- Bind function to KeyframeReached event
if keyframeName == "ElectrocuteEnd" then
canPlay = true
end
end)
animTrack:Play() -- Start the animation
end
end
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Thanks.
Upvote? Thx ;)