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)
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.