How do i make a kill npc for cash script

Okay i know i have only done 1 topic so far and this is my 2nd So here it goes!

I am making a game and i need a fighting system for npc’s but i look up tutorials and it either doesn’t work or seems sketchy .
I got a leaderstats and value set up but i just am not a scripter, Instead i am a Builder
This system relies on the entire Game!
Please give me ideas or a tutorial. I don’t recommend doing scripts but you can put them in if you want. I am thinking about using ai for this but it didn’t work out in the past that well In my other games.

Any help will be super useful and for the other newbies like me use this for help.

Yours Sincerely

  • SoullessContagious
1 Like

i’d Recommend you Create a weapon that “Tags” The NPC so when it dies it knows that “You” Has Killed the “Tagged” NPC and so it knows to give you the cash reward.

this could be done by using a StringValue With the Player’s name As the Value.
Or an ObjectValue With the Player’s Character as the Value.

I will look into that if i later

like as how roblox used to do

  1. add a ob i cant say the letter because of my keyboard. obectvalue which sets to the player

  2. variables

when the npc dies

  1. check for the tagger in game.Players, return if the value is non existent or nil

  2. idk panic search probably

DO NOT DO

in the weapon give cash when it killed a monster
worst mistake of my LIFE!!!

anyways

code:

-- when the monster IS DEAD :rofl: --

Humanoid.Dead:Connect(function()
local TagValue = Humanoid:FindFirstChild('Creator') -- hit value.
if not TagValue then return end if TagValue.Value == nil then return end

-- check for the player thro the value of TagValue and give them their leaderstats
end)

linked sword already has a tag script, in short delete the tag and replace it if it has been found and if it isnt from the guy who attacked the monster
otherwise if there isnt a tag make one and set the value with the player

Ok i will panic search and look into the script But something looks wrong idk what tho

@ pumpkyrofl Where is the cash part of the script?