Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make an animation plays when a player clicks using a tool?

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 answer

✓ Accepted answer

Hi there, I'm sorry to inform you but this is a clear example of a request. This is not a request site, however, if you show us a copy of your current script that you might've written, I'm sure that we will be more than happy to help.

However, at this stage we can not. Thank you.

1 comment

0

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

This discussion is preserved as it was. New answers, comments, and votes are closed.