Kill tracker not working

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to get my kill tracking system working

  2. What is the issue? Include screenshots / videos if possible!
    I have tried multiple things I decided to create a StringValue in replicated storage called “creator” using my guns damage system I wrote a couple lines of code to send the dealer info to the creator string, however, I have noticed it doesn’t send anything.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    As I have said I have tried multiple solutions mainly ones I could think.
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
    The model I’m using is the “Sniper Rifle” model made by roblox the damage script is a moduleScript, I have also tried using other scripts.

local function _defaultDamageCallback(system, target, amount, damageType, dealer, hitInfo, damageData, hum, player)
	if target:IsA("Humanoid") then
		game.ReplicatedStorage.creator.Value = dealer
		print(game.ReplicatedStorage.creator.Value)
		target:TakeDamage(amount)
	end
end
2 Likes

Usually kill credit is done by using “tags”
I suggest putting a folder in the StarterCharacterScripts named “Tags” or whatever feels natural to you and instantiating intvalues. So the idea is that when a player hits another player, check if an intvalue with the player’s name already exists and add to the intvalue the damage dealt if so. Otherwise, create an intvalue with the name of the player and assign the damage to the value. This way if multiple players hit one player then you can code assists. Furthermore, you can check for kill credit from the player that dies rather than from each player that hit them.
I understand that isn’t precisely what you want but it’s a standard system and you can change it accordingly.

1 Like

Thanks for the suggestion, I’m not too bothered about what the solution is, more just trying to get a system that works.
Just a couple questions:

  • Did you mean StringValue not IntValue because I’ve found when I try to use int values and add a string to it, it gives me an error?
  • Should I add the IntValue/StringValue to the folder or get the script to?
  • Would I be able to check “if damage dealt and target.Health == 0 then” add the dealer to the tag folder in the targets tag folder?

If you use an intvalue then you can have
IntValue.Name = Player.Name
and
IntValue.Value = DamageToDo or add more damage
That way when you want to check if a player has already done damage you can just check for
FolderName[Player.Name]

If you were to use a stringvalue then I’m assuming you only want the last hit to grant credit. In which case you’re just assigning
StringValue.Value = Player.Name
Which is less universal.

I’ve found when I try to use int values and add a string to it, it gives me an error?

You cannot perform arithmetic on a string. Use tonumber() or tostring()

Get the script to add the IntValue since you’ll be adding multiple player credit tags. If you only want one then it’s fine to just add it into the character by default.

Use Humanoid.Died to get the event. Don’t use while loops unnecessarily as it uses up resources for no reason.
If you just want kill credit then you only have to add the damage dealer tag to the folder and check for the death separately.

1 Like

I’m not sure if this is what you meant, but I’ve tried this and received the same result.

local function _defaultDamageCallback(system, target, amount, damageType, dealer, hitInfo, damageData, hum, player)
	local tag = game.StarterPlayer.StarterCharacterScripts:FindFirstChild("Value")
	if target:IsA("Humanoid") then
		tag.Name = dealer
		target:TakeDamage(amount)
		if hum.Died then
			print(tag.Name)
		end
	end
end

Also, I was just checking a couple things and I found the “player” value seems to have a tag value, if that might be worth trying?

Why are you changing the value in the StarterCharacterScripts?
You should be changing it from player.FolderNameHere.damagedealername.Value

I’ve adjusted that and still seems to be no result, so I have just done some quick tests:

		print(target)
		print(target.Name)
		print(dealer)
		print(dealer.Name)
		print(player)
		print(player.tag)
		print(player.Name)

this doesn’t give me a single output result, do you have any idea why this might be?

Probably your function then
Your problem appears to lie elsewhere

Ok, thanks for all your help, I’ll try to find a new model somewhere.