Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

Money From Kills?

Asked by 8 years ago

How would you make a script that gives money to a player that has killed another player?

1 answer

Log in to vote
0
Answered by 8 years ago

You don't
Technically

Okay, so here's where it gets tricky. Players don't kill players - Scripts kill players. Scripts know who they're killing, and who they're killing for - And therefore who killed who - But only within the script doing the killing. And this is where the complication comes in:

Most weapons which are compatible with most standards will have some kind of Creator/Killer tag generation for when they damage a Player. This allows the game to know who killed who when the Humanoid died, because it is tagged. If your weapon doesn't support this, you're out of luck.

If it does support this fairly standard-non-standard system of tagging Players, then your code will look something like...

game.Players.PlayerAdded:connect(function(p)
    p.CharacterAdded:connect(function(c)
        c:WaitForChild "Humanoid" .Died:wait()
        local KillerTag = c.Killer;
        if KillerTag then
            KillerTag.Value.leaderstats.Cash.Value = KillerTag.Value.leaderstats.Cash.Value + 300
        end;
    end);
end);

Of course, that all depends on the structure of your game at the end of the day.

Ad

Answer this question