I have tried using String Value to detect if CanDamage is True or False
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
Here is the script:
Blade.Touched:Connect(function(hit)
local enemyH = hit.Parent:FindFirstChild(“Humanoid”)
if enemyH then
if CanDamage.Value == “True” then
if not db then
db = true
enemyH:TakeDamage(5)
wait(0.6)
db = false
end
end
end
end)
I have no idea what ‘db’ is. Dont overthink it, you got the right path, you just need to check if the bool variable your using is true. If so, make the bool value to false and damage the humanoid. Afterwards, add task.Wait(cooldownLength) and once the wait time finishes, make the variable true again.
Blade.Touched:Connect(function(hit)
local enemyH = hit.Parent:FindFirstChildOfClass("Humanoid")
if enemyH then
if CanDamage.Value == true then
if db ~= true then
db = true
enemyH:TakeDamage(5)
delay(0.6,function() -- I changed it because it might yeild the whole script
db = false
end)
end
end
end
end)
repeat wait() until game.Players:GetPlayerFromCharacter(tool.Parent)
local player = game.Players:GetPlayerFromCharacter(tool.Parent)
local db = false
local hum = player.Character:FindFirstChild(“Humanoid”)
local count = 0
local db = false
local CanDamage = script.Damage
local Blade = tool.OldSword.OldBlade
local hold = hum:LoadAnimation(script.Hold)
local A1 = hum:LoadAnimation(script.A1)
local A2 = hum:LoadAnimation(script.A2)
local A3 = hum:LoadAnimation(script.A3)
tool.Activated:Connect(function()
if not db then
db = true
count = count + 1
if count == 1 then
A1:Play()
end
if count == 2 then
A2:Play()
end
if count == 3 then
A3:Play()
count = 0
end
CanDamage.Value = true
Blade.Touched:Connect(function(hit)
local enemyH = hit.Parent:FindFirstChild("Humanoid")
if enemyH then
if CanDamage.Value == true then
if not db then
db = true
enemyH:TakeDamage(5)
wait(0.6)
db = false
end
end
end
end)
wait(0.6)
CanDamage.Value = false
db = false
end
local tool = script.Parent
repeat wait() until game.Players:GetPlayerFromCharacter(tool.Parent)
local player = game.Players:GetPlayerFromCharacter(tool.Parent)
local db = false
local hum = player.Character:FindFirstChild("Humanoid")
local count = 0
local db = false
local db2 = false
local CanDamage = script.Damage
local Blade = tool.OldSword.OldBlade
local hold = hum:LoadAnimation(script.Hold)
local A1 = hum:LoadAnimation(script.A1)
local A2 = hum:LoadAnimation(script.A2)
local A3 = hum:LoadAnimation(script.A3)
tool.Equipped:Connect(function()
hold:Play()
end)
tool.Unequipped:Connect(function()
hold:Stop()
end)
tool.Activated:Connect(function()
if not db then
db = true
count = count + 1
if count == 1 then
A1:Play()
end
if count == 2 then
A2:Play()
end
if count == 3 then
A3:Play()
count = 0
end
CanDamage.Value = true
Blade.Touched:Connect(function(hit)
local enemyH = hit.Parent:FindFirstChild("Humanoid")
if enemyH then
if CanDamage.Value == true then
if not db2 then
db2 = true
enemyH:TakeDamage(5)
wait(0.6)
db2 = false
end
end
end
end)
delay(.65,function()
CanDamage.Value = false
end)
db = false
end
end)