I want to make my animation wait for a couple of seconds after I input my key. But when I tried using wait(number here) it kinda worked.. So when i input my key it waits a couple seconds, and then if you click multiple times during the wait it makes it so that it plays the animation multiple times. Here's the code below.
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:wait()
local canattcak = script:WaitForChild("CanAttack")
local larm = char:WaitForChild("LeftHand")
local rarm = char:WaitForChild("RightHand")
local hum = char.Humanoid
player = game.Players.LocalPlayer
mouse = player:GetMouse()
animation1 = script:WaitForChild("Animation1")
animation2 = script:WaitForChild("Animation2")
enabled = true
mouse.Button2Down:connect(function()
local choose = math.random(1,2)
if choose == 1 then
enabled = false
canattcak = true
local animationTrack = player.Character.Humanoid:LoadAnimation(animation1)
animationTrack:Play()
wait(1)
canattcak = false
enabled = true
elseif choose == 2 then
mouse.Button2Down:connect(function()
enabled = false
canattcak = true
local animationTrack = player.Character.Humanoid:LoadAnimation(animation2)
animationTrack:Play()
wait(1)
canattcak = false
enabled = true
end)
end
end)
