Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Adding points to Killer?[unsatisfied]

Asked by 9 years ago

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

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. Perci1 4988 — 9y
0
confused on what to do with your info perci1 iwilllandonmars 55 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

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.

Ad

Answer this question