I just started to make an combat critical system but i have no clue about that to do it
For example : when you hit a npc or another player theres a small chance(About 5%) to deal an critical hit which deals original damage * critical bonus damage
Is there a way to do it?
Also this is my set up
local Players = game:GetService("Players")
function OnCharAppearance(c)
local critChance = Instance.new("NumberValue", c)
critChance.Name = "critChance"
local critDamageBonus = Instance.new("NumberValue", c)
critDamageBonus.Name = "critDamageBonus"
if critChance.Parent and critDamageBonus.Parent then
print(c.Name.." Critical System Has Been Loaded")
end
end
local function onPlayerAdded(player)
print("P Added")
if player.CharacterAppearanceLoaded then
local c = player.Character
OnCharAppearance(c)
end
end
Players.PlayerAdded:Connect(onPlayerAdded)
local function takeDMG(RealDMG, BonusDMG, CriticalChance)
if math.random(1, 100) <= CriticalChance then
FinalDMG = RealDMG * BonusDMG
else
FinalDMG = RealDMG
end