Kill for Cash not working?

Not my luckiest day today, 2nd time on the Devforum asking for help…

Trying to get my Kill For Cash script working, Thought I did everything right, no errors, what is wrong…

basically the script makes it so that once you kill an npc, you get cash for it.

Please help fix it…

local Humanoid = script.Parent.Humanoid
function Dead()
	local tag = Humanoid:FindFirstChild("creator")
	if tag ~= nil then
		local leaderstats = tag.Value:FindFirstChild("leaderstats")
		if leaderstats ~= nil then
			leaderstats.Points.Value = leaderstats.Points.Value +10
			wait(0,1)
			script:remove()
		end
	end
end
Humanoid.Died:Connect(Dead)
2 Likes

Are you setting tag.Value to the player object?
Try print debugging to see where the script stops.

function Dead() print("died")
	local tag = Humanoid:FindFirstChild("creator")
	if tag ~= nil then
		print("found tag")
		local leaderstats = tag.Value:FindFirstChild("leaderstats")
		if leaderstats ~= nil then
			print("found leaderstats")
			leaderstats.Points.Value += 10
			wait(0.1)
			script:Destroy()
		end
	end
end

Nothing prints, no errors. I don’t know what is going on.

1 Like

Is it a regular script under the NPC? Is the script actually there when you kill the NPC?

Did you just copy & paste my code and forgot to connect the .Died event?

yep, here is my current script, all of my zombies are in a folder in the workspace, would that have anything to do with it?

local Humanoid = script.Parent.Humanoid
function Dead() print("died")
	local tag = Humanoid:FindFirstChild("creator")
	if tag ~= nil then
		print("found tag")
		local leaderstats = tag.Value:FindFirstChild("leaderstats")
		if leaderstats ~= nil then
			print("found leaderstats")
			leaderstats.Points.Value += 10
			wait(0.1)
			script:Destroy()
		end
	end
end
Humanoid.Died:Connect(Dead)

Try:

local Humanoid = script.Parent.Humanoid

function Dead()
	local creator = Humanoid:FindFirstChild("creator")
	if creator ~= nil then
		local ls= game.Players[tag.Value]:FindFirstChild("leaderstats")
		if ls~= nil then
			ls.Points.Value += 10
			wait(0.1)
			script:Destroy()
		end
	end
end
Humanoid.Died:Connect(Dead())

Didn’t work, do i still need the tag? or is it because they are all in a folder?

I changed the variable name from “tag” to “creator”. Whenever the zombie dies there should be a value called “creator” that has a value which is the player who killed the zombie. It must not be making the value. Which weapon system are you using?

function Dead() print("died")
	local tag = Humanoid:FindFirstChild("creator")
	if tag ~= nil then
		print("found tag")
		local leaderstats = tag.Value
		if leaderstats ~= nil then
			print("found leaderstats")
			leaderstats.Points.Value += 10
			wait(0.1)
			script:Destroy()
		end
	end
end

Tell me if it’s working and click on Solution Button!

1 Like

It didn’t work as well as not printing anything in the workspace.

1 Like

Are you putting it under the zombie in a server script? And what weapon system are you using?

if anything is printing, the problem is about the function is not getting executed.

i already had the same problem, the function is correct, but it is not reproducing.

I am using guns that my friend coded, but it didnt work with a regular Roblox sword either. I am putting it under the zombie in the server script as well.

Well some gun systems like (FE) put a value in the character when the player dies. Your weapons do not.

How can I fix this? What value?

Look up “FE Gun Kit”. The value is something the gun script creates that shows who killed the target player.