Hello! I was wondering how to make an animation play when a player clicks with a tool. The example I would be going for is Fisticuffs by Ozzypig: https://www.roblox.com/games/299069113/Fisticuffs I basically want my animation to play every time a user clicks using the tool. Heres my current script
function onClicked() -- Import animation local animation = Instance.new("Animation") animation.AnimationId = "http://www.roblox.com/Asset?ID=399842052"
-- 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 script.Parent.ClickDetector.MouseClick:connect(onClicked)

1 comment
Here is my current script. I'm sorry if it looks bad. I'm not an experienced scripter. function onClicked() -- Import animation local animation = Instance.new("Animation") animation.AnimationId = "http://www.roblox.com/Asset?ID=399842052" -- Local variables local animTrack = nil local canPlay = true function playShockAnim(Source) if canPlay then local player = game.Players.LocalPlayer.Chara