Well, as it is in the title I was wondering how I can avoid these animation bugs
What’s the bug? Is the animation being laggy or something or is that just from the video
Sometimes the animation plays twice instead of once
Ahh, that’s probably a problem with the animation script then, can you send it please?
repeat wait() until game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Animation_Left_Punch = Instance.new("Animation")
Animation_Left_Punch.AnimationId = "rbxassetid://4273582659"
local Animation_Right_Punch = Instance.new("Animation")
Animation_Right_Punch.AnimationId = "rbxassetid://4273585501"
local Animation_Back_Kick = Instance.new("Animation")
Animation_Back_Kick.AnimationId = "rbxassetid://4273590997"
local Animation = {
Animation_Left_Punch,
Animation_Right_Punch,
Animation_Back_Kick
}
local Debounce = false
local Can_Damage = false
UserInputService.InputBegan:Connect(function(InputBegan, GameProcessed)
if InputBegan.UserInputType == Enum.UserInputType.MouseButton1 and not Debounce and not GameProcessed then
Debounce = true
local LoadAnimation = Humanoid:LoadAnimation(Animation[math.random(1, #Animation)])
LoadAnimation:Play()
Can_Damage = true
wait(LoadAnimation.Length * 2)
Can_Damage = false
Debounce = false
elseif InputBegan.UserInputType == Enum.UserInputType.Touch and not Debounce and not GameProcessed then
Debounce = true
local LoadAnimation = Humanoid:LoadAnimation(Animation[math.random(1, #Animation)])
LoadAnimation:Play()
Can_Damage = true
wait(LoadAnimation.Length * 2)
Can_Damage = false
Debounce = false
end
end)