Im trying to add points to an intvalue of a killer after player dies.... I have leaderboard and added the code i am unsure about...
------------Original LeaderBoard
function Entered(player)
wait()
if player:findFirstChild("leaderstats") ~= nil then
player.leaderstats:remove()
end
stats = Instance.new("IntValue")
stats.Parent = player
stats.Name = "leaderstats"
points = Instance.new("IntValue")
points.Parent = stats
points.Name = "Points"
points.Value = 0 --How much you start out--
end
game.Players.PlayerAdded:connect(Entered)
c = game.Players:GetChildren()
for i=1, #c do
Entered(c[i])
end
--------------------------works, i think based on test
function getKillerOfHumanoidIfStillInGame(humanoid)
tag = humanoid:findFirstChild("creator")
if tag ~= nil then
killer = tag.Value
if killer.Parent ~= nil then
return killer
end
end
return nil
end
---------------------------------------------does absolutely nothing idk why
game.Players.PlayerAdded:connect(getKillerOfHumanoidIfStillInGame)
for i=1, #c do
if (getKillerOfHumanoidIfStillInGame(c[i])) then
killer.points.Value = killer.points.Value+5

2 comments
The for loops are pointless, and remember that player added events return player, not humanoid. Thus your getKiller- function will not work with the player added event.
confused on what to do with your info perci1