I tried to do this it didn't work so I believe that I did something wrong. (Yes its a local script.)
01 | local stock = game.Players.LocalPlayer:WaitForChild( "Stocks" ).ONE.Value |
02 | local cash = game.Players.LocalPlayer:WaitForChild( "leaderstats" ).Cash.Value |
03 | local OPrice = game.Workspace.ONEVal.ONEPrice |
04 | local a = game.StarterGui.CashNStuff.Frame.Investments.Buy 1 |
05 |
06 | local stock = tonumber (a.Text) |
07 | a.Text = tostring (stock) |
08 | script.Parent.MouseButton 1 Click:connect( function () |
09 | if cash > OPrice.Value then |
10 | stock = stock + 1 and cash = = cash - OPrice.value and a.Text = = tostring (stock) |
11 | else print ( "Not enough cash" ) |
12 | end |
13 | end ) |
UPDATED still error
You can't compare an integer value to a string value which you do:
1 | if cash = = game.Workspace.Board.SurfaceGui.SmoothGUI.PriceONE.Text |
The cash is an integer (number), while the text is a string value. Possibly using an IntValue object and comparing cash to that, I would suggest using a > sign rather than = would work. Hope this helped!
Johner to fix your error that you commented under JackOfAllBlox's answer, you would use tostring() and tonumber(). This converts the stringvalue of the number to a number, and you could change it back to the string after performing the arithmetic. For example,
1 | local a = game.StarterGui.ScreenGui.Frame.TextLabel.Text |
2 |
3 | local b = tonumber (a) |
4 | b = b + 1 |
5 | a = tostring (b) |
Edit: Actually that script would not work since I did TextLabel.Text I would have to do:
1 | local a = game.StarterGui.ScreenGui.Frame.TextLabel |
2 |
3 | local b = tonumber (a.Text) |
4 | b = b + 1 |
5 | a.Text = tostring (b) |