So i have this script and it gives souls based on percentage damage so for example if you do 90% dmg and someone else does 10% he gets 10% souls and you get 90% but the problem i have is if someone else does 90% dmg and you do 1000% dmg let say you will get 200 Souls (thats how much the entire npcs gives 100%) and the other player will get 180. I want to somehow make it so even if u deal 1000% dmg u will get the remainder of the percentage basically 10% not 100% this is my code right now :
local Mob = script.Parent
local Humanoid = Mob:WaitForChild("Zombie")
local PercentReq = 1 -- Has to do at least 10% of Damage
Humanoid.Died:Connect(function()
for i,v in pairs(Humanoid:GetChildren()) do
if string.sub(v.Name,1,6) == "HitBy:" then
spawn(function()
print("Getting Percentage")
local Percentage = (v.Value/Humanoid.MaxHealth)*100
if Percentage >= PercentReq then
print("Getting Character")
local Char = game.Workspace:FindFirstChild(string.sub(v.Name,7))
if Char then
print("Getting Player")
local Player = game.Players:GetPlayerFromCharacter(Char)
if Player then
print("Getting Stats")
local stats = Player:FindFirstChild("leaderstats")
local killedbandits = Player:FindFirstChild("killedbandits")
if stats then
print("Getting Coins")
local coins = stats:FindFirstChild("Souls")
if coins then
if v.Value >= 100 then
coins.Value = coins.Value + 100 * 2
print("Gave "..Player.Name.." "..(100 * 2).." Coins")
print(Player.Name.." Did "..Percentage.."% Damage")
if killedbandits then
killedbandits.Value = killedbandits.Value + 1
end
else
coins.Value = coins.Value + Percentage * 2
print("Gave "..Player.Name.." "..(Percentage*2).." Coins")
print(Player.Name.." Did "..Percentage.."% Damage")
if killedbandits then
killedbandits.Value = killedbandits.Value + 1
end
end
else
warn(Player.Name.." Coins Not Loaded")
end
else
warn(Player.Name.." Stats Not Loaded")
end
else
warn(Char.Name.." Not Found In Players")
end
end
else
print("Not Enough Damage..."..string.sub(v.Name,7).." Only did "..Percentage.."% Damage")
end
end)
end
end
end)
