What do you want to achieve? Keep it simple and clear!
I want to create a buy all button in an upgrade thats called for example “+1 coin per click”. It increases the amount of coins you would need to buy it by 2 coins. Starting amount is 2.
What is the issue? Include screenshots / videos if possible!
I can’t seem to really find a way to calculate how many coins it would take to buy a specific amount of upgrades. Or in this case, buy all.
And no, im not using for loops since it would pretty much crash roblox if the user had like 1 billion coins which is possible in this game
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve tried looking at dev forums, spent an hour brain storming and still haven’t found a way to implement it.
I’m pretty sure the only way to do this or the best way to do this is via for loops. Roblox WONT crash if they buy like 50 at a time. Roblox only crashes if it goes to the thousands. I’m pretty sure you wont have like 10k weapons. Try making a folder which has all your weapons, after that, insert a int value which will be called the price. Change the int value’s value to the price you want them to be. Then just loop through the weapons folder via a for in pair loop and if the player has enough coins it’ll give them the weapon, and remove the amount of coins they spent, simple.
you wont have 1 billion stuff As long as you dont have a lot of stuff then roblox wont crash! Roblox crashes when it gets thousands of responses in a short amount of time.
Read what i said. Again, i only have a upgrade that increases a NUMBER value (which is better than int value) when upgraded. Not a god damn objects shop
So back to my point, I have an upgrade whereas the cost value increases by 2 every upgrade and the starting price is 2. So how do i calculate the total cost of it?
If you want the value of something to increase by 2 every time an example of it would be this -
-- this is just an example of how to multiply something.
value = Instance.new("NumberValue")
value.Parent = script
value2 = Instance.new("NumberValue")
value2.Parent = script
value2.Value = 100
value.Value = value2.Value * 2 -- 2 is the ammount multiplied by.
I assume you mean increase by a product of 2, not a literal increase of 2, but yes this is how that would be achieved. You may also want to set the value of “value” to an initial value of 0 otherwise it would be nil and could cause issues if referenced before assignment.
When a number value is created the value is automatically 0, you can test this if you create a value through a script and print() the value and it will show up as 0 and not nil.