Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Adding points to Killer?[unsatisfied]

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

0

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.

0

confused on what to do with your info perci1

1 answer

You can test it with studio.

Go Test and select 2 or 3 players (to make sure), press start server and you will play with 3 players at same time. You can also do it for SP sometimes studio load faster that a normal server.

AND REMEMBER THE WAITFORCHILD! You can do :WaitForChild, While not, until etc.

This discussion is preserved as it was. New answers, comments, and votes are closed.