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

How Do I make a leaderboard that shows my kills and also allows me to buy things with the kills?

Asked by 9 years ago

Hello! I'm having a very difficult time, In my game I made a gui to buy different swords, now I would like to make it to where, When I kill a player I get a point (On a leaderboard) And when I get up to a certain amount of kills/points, say 10 i can buy the golden katana, I havent been able to find or make a script compatible as I am very new.... Here's the Script for the button in the gui ****~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~

repeat wait()
    Player = game.Players.LocalPlayer
    Button = script.Parent
    Item = game.ReplicatedStorage:FindFirstChild("Golden Katana")
    Cost = 50
    Money = Player.leaderstats.Money
until

Button.MouseButton1Down:connect(function(purchase)
    if Money.Value > (Cost - 1)then
        Money.Value = Money.Value - Cost
        local a = Item:Clone()
        a.Parent = Player.Backpack
        local b = Item:Clone()
        b.Parent = Player.StarterGear
    end
end)



** ** If you need the actual Gui Script, I will post it as well, please help!

2 answers

Log in to vote
1
Answered by
drew1017 330 Moderation Voter
9 years ago

Well, you've got everything set up correctly within this script, so all that's left is to do the things needed in other scripts.

Assuming you want kills to increase the Money value of the player, you'll need to do this:

First we need to open up the scripts within the weapons in the shop, or really just all weapons potentially available. Find the lines in the scripts that tell the weapon to deal damage -- then in the function that tells it do that, you'll need to add an if statement after the line that deals damage that asks the script whether the humanoid it just hit is dead, AKA whether it's health is 0.

By using that, we can determine that the sword just killed someone, and so using Parent chains you can make the player holding the weapon's Money value to increase. The final code should be something like this:

(dealing damage)
if hit.Humanoid.Health == 0 then
    script.Parent.Parent.Parent.leaderstats.Money.Value = script.Parent.Parent.Parent.leaderstats.Money.Value + (number)
end

-- Ascending up the ancestry, the Parent chain shown above would be the Script, Weapon, Backpack, Player,  respectively.

By the way, you don't have to reduce the cost by 1 -- you can just use the Greater Than or Equal To sign which is >=.

0
Thank you! oveechkin 15 — 9y
Ad
Log in to vote
-1
Answered by 9 years ago

Use the Quenty Store GUI, a lot easier and more efficient. Here's the link, http://www.roblox.com/qShop-Easy-GUI-shop-item?id=69240561

1
You're supposed to ANSWER THE QUESTION, not redirect him to a shortcut. drew1017 330 — 9y

Answer this question