I'm using this simple LocalScript inside of a tool inside ServerStorage being replicated to the player's backpack.
script.Parent.Equipped:Connect(function(Mouse) Mouse.Button1Down:Connect(function() local animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation) animation:Play() print("played") end) end)
(Sorry if formatting errors.) Every time I click, it prints "played" like it's supposed to, without any errors. I have the animation set to the highest priority; it just won't play! I've done everything I could think of! Please help!
ok so as i am aware, mouse button 1 down event is depricated and you should use user input service you can find a lot of tutortials on yt but here's a small example:
local uis = game:GetService("UserInputService") -- here you get the service uis.InputBegan:Connect(function(input) -- this is the input began event. -- there is also a input ended event but stick to this one for now, until you get better local mouseIn = input.UserInputType -- here you define the mouse click --user input service tells the script that you are going to want to detect a mouse input -- there is also KeyCode and it's used in the same way if mouseIn == Enum.UserInputType.MouseButton1 then -- here you check if the player has hit a mouse button, more specifically mb1 end end)
let me know if you need any more help and don't forget to hit that accept answer button if this helped you!
Maybe try using the “Activated” function with the tool.
script.Parent.Equipped:Connect(function() script.Parent.Activated:connect(function() local animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation) animation:Play() print("played") end) end)
Sorry for all the trouble. Turns out my animation itself was broken, and consisted of nothing. I made a new one and it works fine.