Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-3

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

Asked by 8 years ago

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

Log in to vote
0
Answered by 8 years ago

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.

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 funtimecameron886 0 — 8y
Ad

Answer this question