My NPC Isn't Giving Me Cash On Kill

ohhh you can put it as a function that the link i gave it above
and to run a function, place in a activated event when it hit a humanoid!
you just need a character of the player who activate!

I don’t understand what you are trying to say.

i tried to say that:

function getPlayerFromCharacter(character)
 for _, player in pairs(game:GetService("Players"):GetPlayers()) do
if player.Character == character then
 return player
 end
 end
 end

This function will find a player character which match with our character, after the matches, it will return our player which will be a creator value of this topic!

all you need is to call a function like this:

local player = getPlayerFromCharacter(tool.Parent) --because when you equip a --tool, a tool will be placed in a character.
if player then -- when we received a result, it is our player
--make a creator tag
creator.Value = player
end
1 Like

So it’s a new script in ServerScriptService?

no, you just put in the sword script.

I put it in the place when the humanoid is about to get damaged?
I’m sorry if I’m annoying you with all these questions, it’s just that I’m not a very good scripter.

no problem! if it still have an error, you can just call me!
yes, you put in that place

Screenshot 2021-07-08 232337
There is an error that says something with “Consider changing it to local”
Screenshot 2021-07-08 232520
There is an error here saying that there is an Unknown Global “creator”

i can fix! can you show me full? i think you might type it wrong

First change the add a local before a getplayerFromCharacter()
–example local function getPlayerFromCharacter()

(1/2 Pictures)


(2/2 Pictures)

place a function on top of the script!
it wouldnt work there!
–example
–function HERE

–then follow with the other script

Like this?
Screenshot 2021-07-08 233617

the creator that i gave you is an example! i didnt definded it yet!
so the server dont know what creator is? it just a simple script as this!
local CreatorTag = Instance.new(“ObjectValue”)
CreatorTag.Name = “creator”
CreatorTag.Value = player
CreatorTag.Parent = Hum
game.Debris:AddItem(CreatorTag, 2)

–change the creatorTag to “creator”!

yes! now it will work on every line because it is above all!

now after you do it, it will store a damager of a player so if the NPC died they can check on the list of the damager that did to the NPC and find a player that stored in a creator tag!

For some reason I can’t actually do the animation and deal damage.
Any idea how to fix this?

I’m going to go to bed now. I’m going to check back in the morning.

you can try to use Roblox’s default ClassicSword, it have a creatortag data store for simplier working and you can just working out by making only a creatortag detection only!

Nice to you sticking around to help and remaining patient.

I used the ClassicSword, it still doesn’t give me any cells.
Screenshot 2021-07-09 082355