A way you could do it would be a math.random before the damage part. Say you want it to do a crit 20% of the time, you’d do either this

local chance = math.round(100/20) -- Where 20 is the chance of a crit
if math.random(chance) == 1 then
Humanoid:TakeDamage(damage*2)
else
Humanoid:TakeDamage(damage)
end

or this if you want to shorten it a bit

local chance = math.round(100/20) -- Where 20 is the chance of a crit
local newDamage = math.random(chance) == 1 and damage * 2 or damage
Humanoid:TakeDamage(newDamage)

Where Humanoid is the variable containing the Humanoid to damage, and damage being the damage to deal

They both do the same thing, you can use the first one if it’s simpler for you to understand if needed. This is just a basis of h ow you can implement critical hits