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

How to record kills?

Asked by 9 years ago

For example, I wanted a game that records how many kills you have will level you up depending on the amount of kills recorded. I wanted the amount of kills on a GUI. This is my code but unfortunately it did not work and I cannot figure it out. The script is in a tool.

tool = script.Parent

    bullet.Touched:connect(function(hit) -- Consider that this bullet kills a person in one hit
wait(0.1)
    if hit.Parent:FindFirstChild("Humanoid") ~= nil then
        plr = tool.Parent:GetPlayerFromCharacter(hit)
    plr:FindFirstChild("PlayerGui").Kills.Value = plr:FindFirstChild("PlayerGui").Kills.Value + 1 
    end
end)

Too make it complicated, I wanted a script to track if a kill was made, not if a bullet hit a humanoid/player.

Please help? This will help me in the big run.

1 answer

Log in to vote
1
Answered by
Merely 2122 Moderation Voter Community Moderator
9 years ago

PlayerGui gets wiped every time the player dies, so you will lose your stats. It's better to use the leaderstats system. This will make the kill count show up on the player list on the top right corner.

http://wiki.roblox.com/index.php?title=Leaderboards

0
You are right, but if I want to record kills from humanoids that are not players, such as zombies. laughablehaha 494 — 9y
0
Leaderstats works for non-players too. Merely 2122 — 9y
Ad

Answer this question