How would i make a player get gold on someones kill?

The gold value is stored in the Player.
I want to give someone gold if they land the killing blow on a player. Any ideas?
(I use tools.)
I thought of using Humanoid.Died()
But i kinda ran out of stuff to do cus im stupid
(And yes, if you saw me before, i got my account back. Woohoo!)
and uh for context if you wanted to give someone gold you’d do
game.Players.Name.Gold.Value + 50 (or game.Players.LocalPlayer.Gold.Value + 50 if its gonna be a local script)

1 Like

Simple swords that were made wayy back in the day like Linked Swords have a certain method to this. which is basically ceates a ObjectValue within the tagged player. If that player dies then you can see if that object value exists in the player’s humanoid. The ObjectValue would be set to the killing player’s player object. Now, there are of course updated methods to this. Recommendation of mine being CollectionService which would essentially work the same way, just more of a updated and in my opinion more of a micro performance upgrade.

Ah no, i scripted my own tools. They’re not just simple tools.

Yes but the same concept remains. You can still use it as a concept even if they are different.

so how would i see if the killer got the gold? is it going to be a server script?

Im really not that experienced with tools and CollectionService

Yes, you don’t want to put any of this on the client side. You can do a .Died event, I don’t see the problem in that one except if you’re a micro optimization freak like me that would fire a few more times than I would be happy with but judging from the fact that you;re here asking this question I would suggest the simplistic and completely working method that I have suggested for you.

Is this script going to be inside the tool or in ServerScriptService?

And you’d tag the humanoid every time the character is hit with the tool. As I pointed out, older methods use ObjectValues and then setting that object to the player that hit the character in the first place. But another method that I would do for new work just cause I prefer a method like this is to use CollectionService. and no, I’d put it elsewhere. You can have the Died event outside of the tool’s script.

Well, i mostly have no idea how to do it, but i’ll get through it. (Somehow.)

Well practice makes perfect, I’ve been programming for 8 years and am very well versed in a topic such as this. It’s a lot easier than it seems so you’ll get the grasp if you try hard enough.