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

How to record kills?

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

✓ Accepted answer

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

2 comments

0

You are right, but if I want to record kills from humanoids that are not players, such as zombies.

0

Leaderstats works for non-players too.

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