The LocalScript is inside a tool. It is supposed to choose a random animation and play it. The random and animations work but the cooldown i applied doesnt seem to work. Any Help? Here's what you need to see:
debounce = false tool.Activated:Connect(function() if debounce == false then debounce = true local attack1 = hum:LoadAnimation(script.Animation1) local attack2 = hum:LoadAnimation(script.Animation2) local chooseattack = math.random(1,3) if chooseattack == 1 then attack1:Play() end if chooseattack == 2 then attack2:Play() end wait(1) debounce = false end end)
I not that sure if this will work but try it
debounce = false tool = script.Parent --you hadnt set this to anything hum = game:GetService("Players").LocalPlayer.Character.Humanoid -- you hadnt set this either local anims = {script.Animation1,script.Animation2}--stores the animations in an array -- gets a random number from 1 to 2 tool.Activated:Connect(function() if not debounce then -- if debounce is false debounce = true --sets it to true local chooseattack = math.random(2) local animation = hum:LoadAnimation(anims[chooseattack]) --this will load a random animation, from the array, into the player animation:Play() -- plays it wait(1)--waits 1 debounce = false--sets debounce to false end end)