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

How do I make my purchase script only work if they have 100 or more and subtract?

Asked by 3 years ago

So I am making a game called Lemonade Break and I am working on making a script that will have you purchase items when you click on them, but it wont subtract the money, and I am trying to only make it work if they have 100 currency or more

local ToolNames = {"BetterTool"}
local Storage = game:GetService("ServerStorage")
local currencyy = game.Players.LocalPlayer.leaderstats.LemonsAte

local Part = script.Parent
local ClickDetector = Part:WaitForChild("ClickDetector")

ClickDetector.MouseClick:connect(function(Player)
    if Player and Player.Character and currencyy.Value > 99 then
        local Backpack = Player:WaitForChild("Backpack")
        for i = 1, #ToolNames do
            local Tool = Storage:FindFirstChild(ToolNames[i])
            if Tool then
                currencyy.Value =- 100
                    Tool:clone().Parent = Backpack
            end
        end
    end
end)
0
Are you getting any errors? If not try changing the ":connect" on line 8 to ":Connect". TheStarWarsMaster856 12 — 3y
0
YOOOOOOOOOO DiamondComplex 285 — 3y
0
Elaborate. Elaborate. Come on, it shouldn't be hard. Check if the player's currency is 100 or over using >=100, and set their currency. Also, connect is deprecated. Use Connect instead. Capitalize clone. iNot_here 93 — 3y
0
I helped with that but still won't fix the problem. DiamondComplex 285 — 3y
View all comments (2 more)
0
Thank you iNot_here for solving this when DiamondComplex couldnt help at all and was useless pokemon9master29 6 — 3y
0
Yo stfu pokemon fanboi DiamondComplex 285 — 2y

Answer this question