Hello! I was trying to create a click to attack script which plays an animation on click. When I made the script, the only thing that didn't seem to work was the function at the bottom of the script. I took it from a tutorial, so I have no idea at all how to fix it. By the way, I'm not using a tool. I'm using an accessory with a union that has an attachment in ServerStorage.
userInputService = game:GetService("UserInputService")
print("1")
storage = game:GetService("ServerStorage")
print("1")
scissor = storage.ScissorBlade
print("1")
plr = script.Parent.Parent.Character
print("1")
animation = plr.Humanoid:LoadAnimation(scissor.Animation)
print("1")
userInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
print("Attack")
plr.Humanoid.WalkSpeed = 0
animation:Play()
end
end)
Those print("1")s were tests to see if the problem was from any of the variables; all 1s printed successfully. Also, "Attack" did not print. If anyone knows how to fix or make this script better, please write an answer, and thank you!

5 comments
Was "Attack" printed
No
Sorry for not including that, I'll edit it in now.
Humanoid:LoadAnimation() is deprecated. Did you use a localscript or a serverscript? Also why did you put this in ServerStorage?
I'm just using a normal Script. Sorry if normal isn't a very good description, I don't know too much Lua vocabulary..