Hi! I have a script that’s working, but isn’t registering the debounce. Any chance you know how to help me with this?
-
What do you want to achieve? Script registers debounce.
-
What is the issue?
robloxapp-20221225-1758136.wmv (6.4 MB) -
What solutions have you tried so far? Tried adding extra waiting time, nope.
Here’s the code for it.
local Tool = script.Parent
local Cooldown = Tool.Cooldown
local AtkPower = Tool["Attack Power"]
Cooling = false
Active = false
DamageDebounce = false
local Animation = Tool["Swing Animation1"]
local Animation2 = Tool["Swing Animation2"]
local Humanoid = nil
local Character = nil
Tool.Equipped:Connect(function()
Tool.Handle.Transparency = 0
Tool.Handle.Unsheath:Play()
end)
Tool.Activated:Connect(function()
Active = true
local Sword = Tool.Handle
local AnimNumber = math.random(1, 2)
if Tool:FindFirstAncestorOfClass("Model") then
Character = Tool.Parent
if Character:FindFirstChild("Humanoid") and Cooling == false and AnimNumber == 1 then
Cooling = true
Humanoid = Character.Humanoid
local Track = Humanoid:LoadAnimation(Animation)
Track.Priority = Enum.AnimationPriority.Action4
Track:Play()
Sword.Touched:Connect(function(hit)
DamageDebounce = false
local EnemyModel = nil
local Enemy = nil
if Active == true and hit.Parent.ClassName == "Model" and DamageDebounce == false then
DamageDebounce = true
EnemyModel = hit.Parent
if EnemyModel:FindFirstChild("HumanoidE") then
Enemy = EnemyModel.HumanoidE
Enemy:TakeDamage(4)
end
task.wait(0.2)
DamageDebounce = false
end
end)
Track.Stopped:Connect(function()
print("Animation1 ended.")
Active = false
end)
task.wait(Cooldown.Value)
Cooling = false
elseif Character:FindFirstChild("Humanoid") and Cooling == false and AnimNumber == 2 then
Cooling = true
Humanoid = Character.Humanoid
local Track = Humanoid:LoadAnimation(Animation2)
Track.Priority = Enum.AnimationPriority.Action4
Track:Play()
Sword.Touched:Connect(function(hit)
DamageDebounce = false
local EnemyModel = nil
local Enemy = nil
if Active == true and hit.Parent.ClassName == "Model" and DamageDebounce == false then
DamageDebounce = true
EnemyModel = hit.Parent
if EnemyModel:FindFirstChild("HumanoidE") then
Enemy = EnemyModel.HumanoidE
Enemy:TakeDamage(4)
end
task.wait(0.2)
DamageDebounce = false
end
end)
Track.Stopped:Connect(function()
print("Animation2 ended.")
Active = false
end)
task.wait(Cooldown.Value)
Cooling = false
end
end
end)
Tool.Unequipped:Connect(function()
Active = false
DamageDebounce = false
Tool.Handle.Transparency = 1
end)
Got any help or tips? Please send them.