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