Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

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

Asked by
i_Rook 18
4 years ago

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

Log in to vote
1
Answered by 4 years ago

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)
0
Equipped actually does have the mouse as a parameter. youtubemasterWOW 2741 — 4y
0
oops sorry marine5575 359 — 4y
0
Im so stupid. I shoul of read the wiki marine5575 359 — 4y
0
AAAAAAAGGGGGGGGGGGGGGGGGGHHHHHHHHHHHHHHHHHhhh marine5575 359 — 4y
Ad
Log in to vote
1
Answered by 4 years ago

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)
0
Didnt work. i_Rook 18 — 4y
Log in to vote
0
Answered by 4 years ago

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

Answer this question