I have a buy menu for my team game, and I want players to be able to buy gear to help them fight for their team. the whole team can see this menu gui. If someone has any non-zero amount of money, they can put that towards buying the gear by clicking the image button that represents the gear in the menu.
For Example
Jake is on team red. Jake wants to buy a rocket launcher for him and his buddy. the rocket launcher costs 250 dollars, but jake has 123. Jake clicks the gear button, and the cost then reduces to 127. 10 seconds later jake has 127 dollars and he buys the gear. his whole team gets the gear to fight with, and until the end of the match they keep it. at the end of the match, the game resets, and the gear needs to be bought once again.
The background of the image button is transparent, and the gear image is a png. I want the gear icon to be black when it has no money invested in it, but if the gear is paid off up to 33% the background changes to red, and if the gear is paid of up to 66%, the background changes to yellow. After 66%, the background changes to green, and after the gear is paid off it goes dark, and the background is transparent and the gear icon goes semi transparent.
You can try using UIGradients to do this. Or, you can also use a new frame (or image) and just change its size based on how much money is put in. If you are asking how you can go about doing the money system, you can just set a variable for the money needed and keep subtracting from it each time on the server.
local MoneyNeeded = 250
RemoteEvent.OnServerEvent:Connect(function(Player,Money)
if Money >0 and Money <= MoneyNeeded then
MoneyNeeded = MoneyNeeded - Money
--take away the Money spent
RemoteEvent:FireAllClients(MoneyNeeded) --- fire an event to change the money needed icon
elseif Money > MoneyNeeded then
MoneyNeeded = 0
--take away the moneyneeded amount from the players money
RemoteEvent:FireAllClients(MoneyNeeded) --- fire an event to change the money needed icon
end
end)
if you have many items you can do this using a dictionary
local AllMoneyNeeded = {['Coil'] = 50;
['Apple'] = 100
}
RemoteEvent.OnServerEvent:Connect(function(Player,Money,Item)
if Money >0 and Money <= AllMoneyNeeded[Item] then
AllMoneyNeeded[Item] = AllMoneyNeeded[Item] - Money
--take away the Money spent
RemoteEvent:FireAllClients(AllMoneyNeeded[Item],Item) --- fire an event to change the money needed icon
elseif Money > AllMoneyNeeded[Item] then
AllMoneyNeeded[Item] = 0
--take away the moneyneeded amount from the players money
RemoteEvent:FireAllClients( AllMoneyNeeded[Item],Item) --- fire an event to change the money needed icon
end
end)