Hello, I have a problem with making an animation happen on an Mob/NPC. I am trying to make an rpg. I want this animation to happen on the touch of a block, but it doesn't seen to work at all. I used the animation editor plugin to make the animation on the npc and all I need is to make that animation happen when the local player touches a specific block.
I put some code in the block and in the NPC but unsurprisingly it didn't work.
Here is the code for the block:
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/Asset?ID=863113961"
function onTouched()
game.Workspace.Destrioggok.Humanoid:GetPlayingAnimationTracks("http://www.roblox.com/Asset?ID=863113961")
script:play("http://www.roblox.com/Asset?ID=863113961")
end
script.Parent.Touched:connect(onTouched)
Here is the code for the NPC:
-- Import Animation
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/Asset?ID=863113961"
-- Local variables
local animTrack = nil
local canPlay = true
function playShockAnim(Source)
if canPlay then
local playAnimation = game.Destrioggok.Character
canPlay = true
animTrack = game.Destrioggok.Humanoid:LoadAnimation(animation) -- Load animation into Humanoid
animTrack.KeyFrameReached:connect(function(keyframeName) -- Bind function to KeyframeReached event
if keyframeName == "end" then
canPlay = false
end
end)
animTrack:Play() -- Start the animation
end
end
script.Parent:WaitForChild("ShockEvent").OnClientEvent:connect(playShockAnim)
-- Connect remote event to function playing animation
I had no idea what I was doing, but I'm desperate to know how to do it, please help me!!!

3 comments
I'm afraid it didn't work... have any other ideas?
Either its the animation script or you need to make a new method...?I don't have much time to help scripting a proper animation scrip , sorry.
thats fine, thanks for the help!