Help with leaderstats issue

So you do want to give the points and kill to the player, right?

Could I see the whole script you’re using. There may be a line of code somewhere that’s throwing this off

that is the whole script though

Ah, okay.

After this line of code,
local leaderstats = player:WaitForChild("leaderstats")

I want you to add:
print(leaderstats)

If it does find it, then it should print something related to it (it’s name I belive)
If not, it should say nil

Do that and let me know what the output says

nothing on the output when i tested

So nothing printed at all?

If that’s the case then the PlayerAdded event is not firing at all. Are there any other errors in there? If something errors prior to the event call then the script will never get to that point

robloxapp-20230419-1916372.wmv (2.1 MB)"

heres a video so u can get see whats happening

Ah, I see what’s happening now.

You need to add the points every time the mob dies.

So, what you need is a reference to the mob
local mob = --reference to its location in the workspace

Then, we get it’s humanoid
local mobHum = mob:FindFirstChild("Humanoid")

Humanoids have events for when they die, so we can call:

mobHum.Died:Connect(function()
        --code here for adding player stats
end)

Try to implement something like this and let me know where you get to

i tested it got me an error.
moreerroros

This script doesn’t update, unless someone joined the game and if the zombie are dead, it will not reward you, it will instead reward the person that has just joined.

Sorry if my english are bad.

its fine and also i noticed that when i play tested

Try this

local Players = game:GetService("Players")

local Character = script.Parent -- Your mob/character

Character:FindFirstChild("Humanoid").Died:Connect(function() -- If the mob/character died then do the stuff below
	for _, Player in pairs(Players:GetPlayers()) do
		-- Check if the player's character isn't nil
		if Player.Character ~= nil then
			-- Get the mob's/character's HumanoidRootPart, same as for the player's character
			local CharHumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
			local HumanoidRootPart = Player.Character:FindFirstChild("HumanoidRootPart")
			
			-- Get the distance between CharHumanoidRootPart and HumanoidRootPart
			local distance = (CharHumanoidRootPart.Position - HumanoidRootPart.Position).Magnitude
			
			if distance <= 3 then -- Check if the distance is lower that 3 studs
				local Leaderstats = Player:FindFirstChild("leaderstats")
				
				-- Increase Kills by 1, and Points by 2
				Leaderstats:FindFirstChild("Kills").Value += 1
				Leaderstats:FindFirstChild("Points").Value += 2
			end
		end
	end
end)

i got an error when i play tested
moreerroros

Can you show the image of your mob or character on the Explorer?

noobclone

Does the character have humanoid and where did you put the script?

it does have humanoid and its inside of the model
humanoid

The problem is your humanoid is named “Zombie” and my humanoid is named, well “Humanoid”.

As Birdie said, Humanoid is one of those objects where it should retain its original name

i renamed it to the original name and its giving a ton of errors

Well, it’s because your script is trying to get the humanoid that is no longer has the same name, “Zombie”.