I’m trying to fix a bug where if you use the kick animation it breaks the other stuff. Also how would i reduce the amount of lines in this script? I would be happy if someone helped me.
local RS = game:GetService("ReplicatedStorage")
local CombatRE = game.ReplicatedStorage.Combat_RE
local CombatModule = require(game.ReplicatedStorage.CombatModule)
debounce = false
animdebounce = false
------- COMBAT -------
--- Punch1
CombatRE.Punch1.OnServerEvent:Connect(function(plr)
local Damage = CombatModule.Punch1.Damage
if animdebounce == false then
animdebounce = true
local animation = Instance.new("Animation")
animation.Parent = plr.Character.Humanoid
animation.AnimationId = "rbxassetid://8411901505"
local track = plr.Character.Humanoid:LoadAnimation(animation)
track:Play()
game:GetService("Debris"):AddItem(track, 1.2)
wait(1.2)
animdebounce = false
end
if debounce == false then
debounce = true
-------- Damage ---------
local function damage()
plr.Character["Right Arm"].Touched:Connect(function(hit)
if hit and hit.Parent:FindFirstChild("Humanoid") and debounce == true then
debounce = false
hit.Parent.Humanoid:TakeDamage(Damage)
end
end)
end
-------------------------
damage()
wait(1.2)
debounce = false
end
end)
CombatRE.Kick1.OnServerEvent:Connect(function(plr)
local Damage = CombatModule.Kick1.Damage
if animdebounce == false then
animdebounce = true
local animation = Instance.new("Animation")
animation.Parent = plr.Character.Humanoid
animation.AnimationId = "rbxassetid://8412694602"
local track = plr.Character.Humanoid:LoadAnimation(animation)
track:Play()
game:GetService("Debris"):AddItem(track, 1.2)
wait(1.2)
animdebounce = false
end
if debounce == false then
debounce = true
-------- Damage ---------
local function damage()
plr.Character["Left Leg"].Touched:Connect(function(hit)
if hit and hit.Parent:FindFirstChild("Humanoid") and debounce == true then
debounce = false
hit.Parent.Humanoid:TakeDamage(Damage)
end
end)
end
-------------------------
damage()
wait(1.2)
debounce = false
end
end)