I am making some weapons, with chances of having bleeding in them. For this example i use the Basic Knife, which has the chance of 20% to bleed for 20 seconds, dealing 1 damage every second, making that a total 20 damage.
I was trying to make this, there are no errors in the script, but for some reason the script makes a 100% bleedchance, and the bleeding only deals a total of 1 damage.
This is my script:
-- Main variables
local hitbox = script.Parent
canDamage = true
canEffect = true
-- Configurations
damage = 35
reload = 0.75
effectChance = 2 --/10
-- Attack
hitbox.Touched:connect(function(hit)
if (hit.Parent.ClassName == "Model") then
if (hit.Parent:FindFirstChild("HumanoidEnemy")) then
if canDamage == true then
hit.Parent.HumanoidEnemy:TakeDamage(damage)
print(hit.Parent.Name .. " took " .. damage .. " damage")
local randomEffectChance = math.random(1, 10)
print("The number of randomEffectChance = " .. randomEffectChance)
if randomEffectChance == 1 or 2 then
if canEffect == true and canDamage == true then
canEffect = false
print(hit.Parent.Name .. " got an effect")
for i = 0, 20, 1 do
hit.Parent.HumanoidEnemy:TakeDamage(1)
print(hit.Parent.Name .. " is taking 1 damage")
wait(1)
end
end
end
canDamage = false
wait(reload)
canDamage = true
end
end
end
end)
BTW, i made the enemy humanoid another name so you cant damage teammates. I called them "HumanoidEnemy", and there is another working script that makes the animations.
Thanks in advance

1 comment
Shouldn't
if randomEffectChance == 1 or 2 thenbeif randomEffectChance == 1 or randomEffectChance == 2 then?