So, I want to make a combo system where it does more damage when the combo is bigger, but my script is not working. Please help.
local StarterHit = 10
script.Parent.OnServerEvent:Connect(function(Player,Action,V1)
local Combo = Instance.new("NumberValue",Player)
Combo.Name = "ComboVal"
Combo.Value = 0
local dmg = Instance.new("NumberValue",Player)
dmg.Name = "Damage"
dmg.Value = StarterHit
local c = Player.Character
for i, v in pairs(workspace:GetChildren()) do
if v:FindFirstChild("HumanoidRootPart") and v:FindFirstChild("Humanoid") and v:FindFirstChild("Debounce") == nil and v ~= c then
if (v.HumanoidRootPart.Position-c.HumanoidRootPart.Position).Magnitude < 5 then
if Combo.Value == 0 then
Combo.Value += 1
v.Humanoid:TakeDamage(dmg.Value)
print(StarterHit.." damage done.")
elseif Combo.Value > 0 then
dmg.Value = StarterHit + (100 - v.Humanoid.Health)
local function changed()
dmg.Value = StarterHit + (100 - v.Humanoid.Health)
end
v.Humanoid.Health.Changed:Connect(changed)
Combo.Value += 1
elseif Combo.Value == 5 then
dmg.Value = StarterHit + (100 - v.Humanoid.Health)
local function changed()
dmg.Value = StarterHit + (100 - v.Humanoid.Health)
end
v.Humanoid.Health.Changed:Connect(changed)
Combo.Value -= Combo.Value
dmg.Value = StarterHit
end
end
end
end
end)