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 4 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

01local ToolNames = {"BetterTool"}
02local Storage = game:GetService("ServerStorage")
03local currencyy = game.Players.LocalPlayer.leaderstats.LemonsAte
04 
05local Part = script.Parent
06local ClickDetector = Part:WaitForChild("ClickDetector")
07 
08ClickDetector.MouseClick:connect(function(Player)
09    if Player and Player.Character and currencyy.Value > 99 then
10        local Backpack = Player:WaitForChild("Backpack")
11        for i = 1, #ToolNames do
12            local Tool = Storage:FindFirstChild(ToolNames[i])
13            if Tool then
14                currencyy.Value =- 100
15                    Tool:clone().Parent = Backpack
16            end
17        end
18    end
19end)
0
Are you getting any errors? If not try changing the ":connect" on line 8 to ":Connect". TheStarWarsMaster856 12 — 4y
0
YOOOOOOOOOO DiamondComplex 285 — 4y
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 — 4y
0
I helped with that but still won't fix the problem. DiamondComplex 285 — 4y
View all comments (2 more)
0
Thank you iNot_here for solving this when DiamondComplex couldnt help at all and was useless pokemon9master29 6 — 4y
0
Yo stfu pokemon fanboi DiamondComplex 285 — 3y

Answer this question