Handling Player Tags

Hi,

Although I know the “Classic” way of creating Player Tags, which Involves a ObjectValue Parented to the Targets Humanoid under the name creator, so when they die, you can check this value for the Last Player who hit the Player, like so:

local creator  = Instance.new("ObjectValue") -- ObjectValue
creator.Name   = "creator" -- Name
creator.Value  = Player -- Assigns the creator as the Player
creator.Parent = Humanoid -- Parents to Target Humanoid
Debris:AddItem(creator, 3) -- Removes Tag after 3 Seconds, or when another Player tags them
Humanoid.Died:Connect(function()
    local killer = Humanoid:FindFirstChild("creator") -- looks for 'creator' tag
    if killer then -- if creator tag exists
        local Player = killer.Value -- gets Player Value
        if Player then -- if there is a Value
            Player.Cash.Value += Amount -- Adds amount to Player
        end
    end
end)

This Appearently isnt a good way to do it, so now im wondering on how should I be Handling it?

1 Like

This is actually fine to do, it’s just that people recommend using a custom module to handle all weapons in order to check which player killed who, but this is more complicated with only minimal benefits.

You should use whatever fits your game best, but I believe what you suggested is a suitable option.

2 Likes

I agree with @Katrist. As they said, it also depends on what fits your game best. If you wanted to get the last person who hit the player then this option is fine. However, some people like to complicate it. For example, give the kill to the person who did the most damage, but the last hit (if done by someone else) could be counted as an assist. Same with players who might do damage before that.

In that case, yes, you might want to use a different system.

1 Like

This can actually be done using the same system as I shown, it isnt that complicated.

1 Like

Yes, I’m sorry. I didn’t think much of it. But yeah you’re right, so I mean you can use the same system, unless you wanna do something else that would require you to change it.

Please don’t feel like your code needs to be complex in order to be good, that’s not always the case. In fact, writing overly complex code can make it harder to maintain and debug in the long run. It’s important to make sure your code works and that it’s easy to manage!

2 Likes

I wonder who would think this way.


Typically the more Advanced are the more efficient ways of doing it, It being Harder to Debug is a Normal Process when making Advanced codes, and Harder to Maintain depends on how you Handle it, otherwise it would still be easy to manage.

While it is true that more advanced methods and algorithms can often result in more efficient code, this is not always the case. Sometimes, simpler code can actually be more efficient and easier to optimize.

As for debugging, with more advanced code, there are often more potential points of failure, more intricate control flow, and more intricate dependencies between different components. This can make it more difficult to identify and fix bugs when they occur.

The key is to use best practices such as writing clear and concise code, and thoroughly testing the code to catch potential bugs early. By doing so, you can minimize the amount of time and effort required to debug advanced code, making the development process smoother and more efficient.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.