I just created the following script:
-- Import animation local animation = Instance.new("Animation") animation.AnimationId = "http://www.roblox.com/Asset?ID=146374944" -- Others MyMouse = mouse MyMouse.Button1Down:connect(playAnim) -- Local variables local animTrack = nil local canPlay = true function playAnim(Source) if canPlay then local player = script.Parent.Parent canPlay = false animTrack = player.Humanoid:LoadAnimation(animation) -- Load animation into Humanoid wait(2) canPlay = true end animTrack:Play() -- Start the animation end
But it gives me the following Error:
18:32:57.308 - Workspace.Player1.ID [C5].Script:20: attempt to index global 'mouse' (a nil value)
18:32:57.310 - Script 'Workspace.Player1.ID [C5].Script', Line 20
18:32:57.310 - stack end
How can I fix it. Please note the following: -This is a tool -This is supposed to run an Animation in the Humanoid. It works perfectly without MouseClicks
You're not using any events here!
mouse isn't just some magical global variable, you need to get it from somewhere. The mouse object is given as the first argument in the
Equipped event of tools.
script.Parent.Equipped:connect(function(mouse) mouse.Button1Down:connect(function() print("Blockhaak down!") end) end)