I'm quite new to coding, and this is something I haven't been able to figure out for months, and none of the research I've been doing is helping.
My goal is to make a tool, (in this case, Ice Cream) and when you click with said tool equipped, it plays the animation I wish to play (in this case, the person taking a lick of the ice cream)
I've done research on various sites, and this is the code I came up with-
-- Import animation
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/Asset?ID=1851375372"
-- 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
local onActivation()
canPlay = true
end
end)
animTrack:Play() -- Start the animation
end
end
I tried my best to retain from errors, But so far, nothing happens when I equip the item and try to activate it. It would help if someone told me what I was doing wrong.

2 comments
I'm afraid it didn't work. Your script didn't return any errors, but nothing happened.
I should warn you about something however... the animation will stop once your character starts walking, so... i have edited my script.