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

How do I make a kill/cash system?

Asked by
16079 3
3 years ago

I want to make a game where if you kill someone with a weapon, you get cash from it,

but I also want your cash to save when you leave the game and rejoin.

I also want to code a leaderboard that shows who has the most cash only. (does not show amount of kills)

I really don't know how to code well. I once spent weeks making a cash system once in the past and failed.

Please if anyone knows any scripting or has any tips on where to start, I need help

(like should I start first on making a script for killing someone and earning cash from it?) (should I create a leaderboard first?)

(or should I be making the script that allows player data to save even when they leave the game first?)

(Also I sort of know how to make a weapon a player holds, swing at another player and the player dies when their health hits 0 but I kind of forgot how.. I have not touched upon learning how to code in more than a year..)

Please all help appreciated ! thank you for reading

1
Just search it up on youtube, there's plenty of tutorials that answer all your questions. Mathilinium 112 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

I did not find all you wanted like save or not show kills but I did find cash

game.Players.PlayerAdded:connect(function(player)

    local leaderstats = Instance.new("Folder",player)
    leaderstats.Name = "leaderstats"

    local cash = Instance.new("IntValue",leaderstats)
    cash.Name = "Cash" -- name of cash
    cash.Value = 0 -- how much you wanna start out with

    local kills = Instance.new("IntValue",leaderstats)
    kills.Name = "Kills" -- name of kills
    kills.Value = 0


    player.CharacterAdded:connect(function(character)
        character:WaitForChild("Humanoid").Died:connect(function()

            local CreatorTag = character.Humanoid:FindFirstChild("creator")

            if CreatorTag and CreatorTag.Value then

                local stats = CreatorTag.Value:WaitForChild("leaderstats")

                stats["Cash"].Value = stats["Cash"].Value + 20 -- how much cash to give per kill
                stats["Kills"].Value = stats["Kills"].Value + 1    -- how much kills you  get when you kill one person     
            end
        end)
    end)
end)
0
Don't steal other peoples work. You should only answer questions with scripts that you wrote yourself. DietCokeTastesGood 111 — 3y
Ad

Answer this question