So i have a script that gives you Souls depending on how much % damage you did and it works for multiple people so if u did 90% dmg u get 90% Value and the other person gets 10%. This script only works if you do the damage with Melee Weapons such as swords. I have a ranged weapon and i want it to work for it too. Idk how exactly local Tag = Humanoid:FindFirstChild("creator") somehow has to be implemented in the script.
local Mob = script.Parent
local Humanoid = Mob:WaitForChild("Humanoid")
local PercentReq = 10 -- 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")
if stats then
print("Getting Coins")
local coins = stats:FindFirstChild("Souls")
if coins then
coins.Value = coins.Value + Percentage * 2
print("Gave "..Player.Name.." "..(Percentage*2).." Coins")
print(Player.Name.." Did "..Percentage.."% Damage")
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)

1 comment
try using mouse.target to give the value. BTW you can use :FindFirstChild() instead of for loops and spawn() has a delay at the begining