Infinity storage

I’m trying to make an infinity storage for a back pack but roblox studio isn’t recognizing infinity but works for other values.

So it works for storing 10,000 values etc but for infinity (I just did 100000 ^ 1000000) and once the players hits reach the required value, a GUI would pop up. It works for all the other values (meaning it would fill the hits until it reaches 10,000 or something).

But for infinity, the GUI pops up even though I didn’t click anything. Why doesn’t roblox detect infinity, is there any other to write infinity as a number that roblox will recognize?

NOTE: To check if it is infinity, I did:

print(100000 ^ 1000000)

And the result I got was inf

1 Like

Not an exact solution, and others will likely post better ones, but could you not disable the check script for the infinity backpack?

There is no error. So the value of the player backpack turns to infinity if they buy the pass. But when it’s infinity, the GUI pops up.

My guess is that this is happening because you’re trying to get a number so high that it goes negative, no real way to be sure, though.

Roblox’s “infinity” is math.huge which AFAIK is the largest possible number available in Roblox Lua, you should try using this instead of 10000^10000

The GUI still keeps popping up.

So this is my code:

	local playerHammerPack = Instance.new("IntValue",playerStats)
	playerHammerPack.Name = "PlayerHammerPack"
	playerHammerPack.Value = HammerPacks["Infinity Hammer Pack"]
	
	print(HammerPacks["Infinity Hammer Pack"])

while wait() do	
	if bumpStorage.Value > playerHammerPack.Value then
			print("Exceeded!")
			bumpStorage.Value = playerHammerPack.Value
			game.ReplicatedStorage.RemoteEventsFolder.HammerPackFullEvent:FireClient(player)
		end
	end

Inside the Module Script:

	["Infinity Hammer Pack"] = math.huge

EDIT: If I switch that with any other pack value, it works completely fine.

This is a bit unclear. What exactly are you trying to accomplish? Do you mean an inventory with an infinite amount of space? Some images might help.

Couldn’t you just explicitly check if their hammer pack is Infinity Hammer Pack? You might have to reconstruct your code a bit, hammerPacks is the hammerPack module:

local playerHammerPack = Instance.new("StringValue",playerStats)
playerHammerPack.Name = "PlayerHammerPack"
playerHammerPack.Value = "Infinity Hammer Pack"
---
['Infinity Hammer Pack'] = 'inf'
---
if hammerPacks[playerHammerPack.Value] ~= 'inf' then
	if bumpStorage.Value > playerHammerPack.Value then
		print("Exceeded!")
		bumpStorage.Value = playerHammerPack.Value		 
   		game.ReplicatedStorage.RemoteEventsFolder.HammerPackFullEvent:FireClient(player)
	end
end

So, basically I have a module script called Hammer Packs which have different packs inside with their values. Ex:

["Infinity Pack"] = math.huge;

And then, when a player buys something (packs), I set the pack(value) as the playerHammerPack.Value. So if the bump Storage value is greater than the player’s hammer pack value, then the code is run.

Nothing can be bigger than math.huge, add an equals sign after the > sign.

inf is any number greater than or equal to 2^1024 - 1 (in terms of math.huge). So you could just check if a number is equal to math.huge (any number equal to or greater than 2^1024 - 1)

print(10^4 >= math.huge) -- false, 10,000 is not inf
print(10^1000 >= math.huge) -- true, 10^1000 is greater than 2^1024 - 1, inf

Assuming you’re using NumberValues, 1e+308 is the highest value you can store. Make the storage value that since for most intents and purposes people won’t be reaching that value.

(Incase 1e+308 isn’t recognised by a script, change it to 1*10^308)

Instead of actually trying to get an infinite number, it’s usually best to set the value to an arbitrarily high number and just manually change any text you need to.

maybe try with math.huge

It should be inf too

That’s what I’m saying, if bump storage never crosses math.huge then the GUI will never pop up, but the GUI keeps popping up.

1 Like

I’m not trying to find infinity though. Even when I changed infinity to

math.huge

it still doesn’t work. The GUI keeps popping up even when it adds 1 to the bump but it’s not supposed to.

I don’t know how ROBLOX scripted the backpack because I’ve never looked into the script.

But there is a phenomenon you can see when you use NumberValues when you try to set the NumberValue to a very high value (I forgot the exact value, it’s something in Base64 iirc), the number goes negative.

If ROBLOX does anything similar for the backpack, then your problem may be that it is taking [Inf] to be a negative value.

I noticed some other replies mentioning something similar, so I’m sorry if this point was already discarded.

use math.huge (reference: math (roblox.com))

1 Like

It doesn’t work. I already tried doing that as someone else told me to use previously.

2 Likes

Nvm, I figured out what to do.

while wait() do	
	if bumpStorage.Value > playerHammerPack.Value and playerHammerPack.Value == not HammerPacks["Infinity Hammer Pack"] then
			print("Exceeded!")
			bumpStorage.Value = playerHammerPack.Value
			game.ReplicatedStorage.RemoteEventsFolder.HammerPackFullEvent:FireClient(player)
		end
	end

I bypassed this by setting it not equal to Infinity.