I am trying to make a click to play animation script, but it wont work! Does it not work on studio, or did I write something wrong?
script.Parent.Equipped:Connect(function(Mouse) Mouse.Buttom1Down:Connect(function() local Animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation) Animation:Play() end end)
Please help me if you know. Thanks alot :)
For a tool, use the tool script.Parent.Activated and Equipped does not pass a mouse. and you missed a closing bracket line 5 Also, learn how to enable the output panel, this will help you a lot
script.Parent.Equipped:Connect(function() Script.Parent.Activated:Connect(function) local anim =game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation) anim:Play() end) end)
Hello. Instead of using Mouse.Button1Down
, use Tool.Activated
. A tool automatically gets activated when a player clicks while the tool is equipped. Try this:
script.Parent.Activated:Connect(function() local Animation = game:GetService("Players").LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation) Animation:Play() end end)
Try this:
script.Parent.Activated:Connect(function() -- Activated is like a click, but when its equipped only. No need for the "script.Parent.Equipped:Connect(function(Mouse)" local Animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation) Animation:Play() end
Tell me and accept if it works