Hey! I'm currently in the process of making a tycoon game. When the player buys the seating, for 5$, it will take away value (which is something I don't know how to do yet). There's an IntValue inside of the money text.
ProximityPrompt:
1 | local remEvent = game.ReplicatedStorage.Remotes:WaitForChild( "TakeCashSeating" ) |
2 |
3 | script.Parent.Triggered:Connect( function (player) |
4 | remEvent:FireClient(player) |
5 | end ) |
LocalScript in StarterGUI:
01 | local remEvent = game.ReplicatedStorage.Remotes:WaitForChild( "TakeCashSeating" ) |
02 |
03 | remEvent.OnClientEvent:Connect( function () |
04 | if script.Parent.ScreenGui.changecolor.currency.money.Value > = 5 then |
05 | script.Parent.ScreenGui.changecolor.currency.money.Value = 0 |
06 | script.Parent.ScreenGui.changecolor.currency.money.Text = s cript.Parent.ScreenGui.changecolor.currency.money.Value |
07 | else |
08 | script.Parent.ScreenGui.changecolor.currency.errornote.Visible = true |
09 | script.Parent. error :Play() |
10 | wait( 1.1 ) |
11 | script.Parent.ScreenGui.changecolor.currency.errornote.Visible = false |
12 | end |
13 | end ) |
Any working answer is appreciated.
The greater than or equal to sign is >=, which I see you are already using in your script. I recommend you take a look at this page if you simply want to know operators, although they don’t seem to be your problem. You are trying to set .Text and .Value of an instance, and you aren’t removing the $5, just setting the value to zero. This code below assumes that the IntValue is named IntValue and is parented to script.Parent.ScreenGui.changecolor.currency.money.
01 | local remEvent = game.ReplicatedStorage.Remotes:WaitForChild( "TakeCashSeating" ) |
02 | local currency = script.Parent.ScreenGui.changecolor.currency |
03 |
04 | remEvent.OnClientEvent:Connect( function () |
05 | if currency.money.IntValue.Value > = 5 then -- has enough money |
06 | currency.money.IntValue.Value = currency.money.IntValue.Value - 5 --take away 5 from money |
07 | currency.money.Text = currency.money.IntValue.Value --set text |
08 | else --not enough money |
09 | currency.errornote.Visible = true |
10 | script.Parent. error :Play() |
11 | wait( 1.1 ) |
12 | currency.errornote.Visible = false |
13 | end |
14 | end ) |