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

1 comment
local mouse = player:GetMouse()