Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

My click tool for animation script not work. What did I do wrong?

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 :)

3 answers

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

Solution:

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)

4 comments

0

Equipped actually does have the mouse as a parameter.

0

oops sorry

0

Im so stupid. I shoul of read the wiki

0

AAAAAAAGGGGGGGGGGGGGGGGGGHHHHHHHHHHHHHHHHHhhh

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)

1 comment

0

Didnt work.

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

This discussion is preserved as it was. New answers, comments, and votes are closed.