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

How to make a gun that tracks kills?

I have no idea how to track kills. Also Im not asking for scripts

1 comment

0

No script requests.

1 answer

You can make a kill marker for a gun

The person shooting the gun.

--not regarding a gun script, just what you would do to detect in that scenario
Player = game.Players.LocalPlayer
gundamage = 20
bullet.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local hum = hit.Parent.Humanoid
		if hum.Health == 0 then
			return
		elseif hum.Health - gundamage <= 0 then
			Player.leaderstats.Kills.Value = Player.leaderstats.Kills.Value + 1
		end
	end
end)

This will check if when the gun is shot and it successfully hits the target then it will check if when it hits it the product health is either 0 or lower, if it is then it will add a kill to its leaderstats ( taking in mind that maybe you've created a leaderboard )

~tantec

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