My NPC Isn't Giving Me Cash On Kill

Is there a way to give cells on kill without using the creator tag?

Oh, I see the issue now.
Screenshot 2021-07-09 192833
it has an error saying that there is no player
Screenshot 2021-07-09 192846

The character is the actual players model not the player itself. But it is hard to get this without a remote event. You should use a remote event which passes on the players data.

try using the classic sword then do a script in the NPC!

script.Parent.Humanoid.Died:Connect(function() --humanoid died function
local creatortag = script.Parent.Humanoid:FindFirstChild("creator")
if creatortag then --if npc didnt die by accident
local killer = creatortag.Value --this defined as a killer! now we want to give player a score
kill.leaderstats.Cells.Value = 10 --give player a cells value to 10 (set to 10 not add by)
end
end)

@B4Mp4 please try it first!, sorry i just woke up!

i sure it doesnt have! because damaging a humanoid just taking it only a damage, just a damage without storing a killer data

Iā€™ve found an issue with the ClassicSwordā€™s Script.
Screenshot 2021-07-09 214544 Screenshot 2021-07-09 214556
which causes:
Screenshot 2021-07-08 224727

that means that you did right
just change the .leaderstats to :WaitForChild(ā€œleaderstatsā€)

Ok, so it still didnt work, maybe I need to totally remake the sword and the Npc.
robloxapp-20210709-2150127.wmv (1.7 MB)

1 Like

ima do it for you! please wait!!

this is the function that every roblox weapon have:
function TagHumanoid(humanoid, player)

local Creator_Tag = Instance.new("ObjectValue")

Creator_Tag.Name = "creator"

Creator_Tag.Value = player

Debris:AddItem(Creator_Tag, 2)

Creator_Tag.Parent = humanoid

end

this were used to put a creator tag!

ok so i fixed it, this is what it should work!


as you can see in the output! it have a killer name appeared!
i already have a place file if you need it.
@B4Mp4

Ok, Iā€™m gonna need to see where to put the piece of scriptā€¦

no, i got a problem already! i think it because on the creator tag on the classicsword.
change the line
Creator_Tag.Parent = humanoid
above
Debris:AddItem(Creator_Tag, 2)
so it will place in a humanoid after it get deleted!

the death detector (put a script inside a dummy) and type:

script.Parent.Humanoid.Died:Connect(function()
	print("Ded")
	local tag = script.Parent.Humanoid:FindFirstChildOfClass("ObjectValue")
	if tag then
		local killer = tag.Value
		print("Player"..killer.Name.." killed me!!")
	end
end)

if you still got a problem, iā€™ll just send you a rbxl file

Could you send me the rbxl file? I think I need to analyze it to see what Iā€™m doing wrong.

Sure!
bookgamerycreatortag.rbxl (37.6 KB)
if it work then you can tell me!

3 Likes

THANK YOU!!! It finally works!
:grinning:

1 Like