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

ROBLOX - leaderstats and buying. any help?

Asked by 2 years ago

Basically, I've made it so when a GUI button is pressed, it gives the player a tool. Now I am trying to make it so you need a certain amount of cash to buy it. I have already made the leaderstat for the cash, so now I just need to make it so you can buy it and it takes away the amount of money. I would like it so it costs 100 cash. Here is my script:

local Button = script.Parent
local Gun = game.ReplicatedStorage.Weapons.Pistol
local Players = game:GetService("Players")
local player = Players.LocalPlayer

Button.MouseButton1Click:Connect(function(player)
    local leaderstats = player:FindFirstChild("leaderstats")
    local Cash = leaderstats and leaderstats:FindFirstChild("Cash")
    if Cash > 99 then
        Cash =- 100
        Gun:Clone()
        Gun.Parent = game.Players.LocalPlayer.Backpack
    end
end)

All answers appreciated! Thanks!!

1 answer

Log in to vote
0
Answered by 2 years ago

I found a Youtube tutorial on what you are wanting hope this helps: https://www.youtube.com/watch?v=uVUCaFs4Bh4

Note this tutorial is showing you how to make a gui tool shop. Also he may show how to make the leaderstats with cash, but you can skip that part.

Ad

Answer this question