Animations on click?

Hello, I’m an absolute noob when it comes to scripting, so I need help putting an attack animation on players.

After reading this:, I had no idea where to put the scripts anyway. I’m sorry if this is a simple question.

Basically, how am I supposed to make the animation run (on players), when they left click? Also, will this work with any button (A, right click, D, etc.)?

1 Like

could try this

lp = game.Players.LocalPlayer
mouse = lp:GetMouse()
anim ='Animation')
anim.AnimationId = "rbxassetid://id'
1 Like

Use UserInputService
Animations should always be client side

local UserInputService = game:GetService("UserInputService")
 local player = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")

UserInputService.InputBegan:Connect(function(Input, gameProcess)
if Input.KeyCode == Enum.KeyCode.D then
--this if you want it to be a key.
if Input.UserInputType == Enum.UserInputType.MouseButton1 then
-- this is if you want to be a mouse click
local Animation = -- Make an animation object put in the script  and place animation Id in object)
local AnimationLoad = humanoid:LoadAnimation(Animation)
AnimationLoad:Play() -- How to tell the script when to start the animation.
1 Like

I’ll try those out, thank you!