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?
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.
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.
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.
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.
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.