Hi, im trying to play an animation when the player clicks, but nothing is happening. There is also no output.
01 | local plr = game.Players.LocalPlayer |
02 | local mouse = plr:GetMouse() |
03 | local anim = Instance.new( "Animation" ) |
04 | anim.AnimationId = "http://www.roblox.com/Asset?ID=2309234897" |
05 | local char = plr:WaitForChild( "Character" ) |
06 | local equipped = false |
07 | local tool = script.Parent |
08 |
09 | mouse.Button 1 Down:Connect( function () |
10 | if equipped = = true then |
11 | local animTrack = char.Humanoid:LoadAnimation(anim) |
12 | animTrack:Play() |
13 | wait( 2 ) |
14 | end |
15 | end ) |
Maybe, this will work, We can try switching the statements, by making the equipped function first and then the mouse.Button1Down
localscript:
01 | local plr = game.Players.LocalPlayer |
02 | local mouse = plr:GetMouse() |
03 | local anim = Instance.new( "Animation" ) |
04 | anim.AnimationId = "http://www.roblox.com/Asset?ID=2309234897" |
05 | local char = plr:WaitForChild( "Character" ) |
06 | local equipped = false |
07 | local tool = script.Parent |
08 |
09 | tool.Equipped:Connect( function () |
10 | mouse.Button 1 Down:Connect( function () |
11 | local animTrack = char.Humanoid:LoadAnimation(anim) |
12 | animTrack:Play() |
13 | wait( 2 ) |
14 | end ) |
15 | end ) |