Então, eu tenho um script sobre o inimigo que quando ele morre ele dá a recompensa para todos os jogadores que o atacaram, mas ele não está dando para todos, mas apenas para o primeiro jogador que o atacou. Como eu posso fazer isso?
Enemy bounty script:
local Enemy = script.Parent.Humanoid
function KillForXp()
local tag = Enemy:findFirstChild("creator")
local folder = script.Parent.HittedPlayers
for i,v in pairs(folder:GetChildren()) do
if v:isA("StringValue") then
local give = game.Players[v.Name]
if tag ~= nil then
if tag.Value ~= nil then
local Data = tag.Value:findFirstChild("Data")
local leader = tag.Value:FindFirstChild("Quest")
local leaderplr = give:FindFirstChild("Quest")
if leader.Num.Value == script.Parent.Data.Num.Value then
if leader ~= nil then
leaderplr.Kills.Value = leaderplr.Kills.Value + 1
end
end
if Data ~= nil then
give.Data.Gold.Value = give.Data.Gold.Value + 50
give.Data.Exp.Value = give.Data.Exp.Value + 50
wait(0.01)
script:Destroy()
folder:ClearAllChildren()
end
end
end
end
end
end
Enemy.Died:connect(KillForXp)
In the player’s attack script it looks like this:
function ShareExp(humanoid, player)
if not humanoid.Parent.HittedPlayers:FindFirstChild(player.Name) then
local a = Instance.new("StringValue")
a.Value = player.Name
a.Name = player.Name
a.Parent = humanoid.Parent.HittedPlayers
end
end