i Made a script that when you kill a Npc you get rewards from killing him but when i do it rewards all players? Its a really werid bug, the script is inside the npc. please ask if you need anymore information thank you for reading.
local Informations = require(game.ReplicatedStorage:WaitForChild("Informations"))
local mob = Informations["Mob"][script.Parent.Name]
script.Parent.Humanoid.Died:Connect(function()
local target = {}
for _,v in pairs(script.Parent.Humanoid:GetChildren()) do
if v:IsA("ObjectValue") and v.Name == "creator" then
table.insert(target, v)
end
end
if #target ~= 0 then
for _, v in pairs(target) do
print(v)
if v.Value ~= nil then
local PlayerData = v.Value.Data
PlayerData.Exp.Value += mob["Exp"] * PlayerData.RealExpEvent.Value
PlayerData.Beli.Value += mob["Beli"]
game.ReplicatedStorage.Remotes.Reward:FireClient(v.Value, "Earned " .. mob["Exp"] * PlayerData.RealExpEvent.Value .. " Exp", Color3.new(0.992157, 1, 0.490196))
game.ReplicatedStorage.Remotes.Reward:FireClient(v.Value, "Earned " .. mob["Beli"] * PlayerData.RealExpEvent.Value .. " Beli", Color3.new(0.203922, 0.737255, 0.121569))
if PlayerData.Type.Value == mob["Type"] then
PlayerData.Amount.Value += 1
end
end
end
end
end)