Hello, I’m an absolute noob when it comes to scripting, so I need help putting an attack animation on players.
After reading this: https://developer.roblox.com/en-us/articles/using-animations-in-games, 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.)?
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")
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.
I’ll try those out, thank you!