Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make numbers go higher than what Roblox allows for IntValues?

Asked by
IsPoyo -1
5 years ago
Edited 5 years ago

So I've made a leaderboard and it is using IntValues. Apparently it has a cap of 2,147,483,647 or so. I want to find a way to make a number system that goes farther than that. Would I have to use just a gui to display your stats, or can I add a part of script to make the cap go further? function onPlayerEntered(newPlayer)

The leaderboard script:

 function onPlayerEntered(newPlayer)

wait(.5)

local stats = Instance.new("IntValue")

stats.Name = "leaderstats"



local score = Instance.new("IntValue")

score.Name = "Blocks"

score.Value = 10



score.Parent = stats

stats.Parent = newPlayer

local score2 = Instance.new("IntValue")

score2.Name = "Multi"

score2.Value = 2



score2.Parent = stats

stats.Parent = newPlayer

end



game.Players.ChildAdded:connect(onPlayerEntered)

I can also add other scripts , like the one I am using to add to the IntValue, or the one I use for the GUI stat display. Just tell me if I need those.

0
just make it go up to 1000 then add prefixes. greatneil80 2647 — 5y
0
How do I do that? IsPoyo -1 — 5y
0
The actual maximum an integer value in roblox can represent is close to the 64 bit integer limit of 9,223,372,036,854,775,807, or 2^63 - 1, as opposed to 2,147,483,647, which is 2^31 -1 theking48989987 2147 — 5y

4 answers

Log in to vote
0
Answered by 5 years ago

I saw you post a previous forum on converting numbers to exponential form. Here is a DevForum I found that might help you: https://devforum.roblox.com/t/most-efficient-way-of-converting-a-number-in-scientific-notation-into-a-suffix-and-back/178431

If your NumberValue is actually too big, you can use a StringValue. Just make sure to tonumber() it to do calculations with it and then tostring() it back when setting the StringValue.

Ad
Log in to vote
0
Answered by 5 years ago

You could do

local int1 = 2147483647
local multiplier1 = 1

while true do
    wait()
    print(int1 * multplier1)
end

but i don't know how well it would work.

Log in to vote
0
Answered by
IsPoyo -1
5 years ago

I have tried changing the numbers from EmeraldSlash's answer but I get the error, "Workspace.Suffixes:9: attempt to concatenate field '?' (a nil value)" Here is the script:

local Suffixes = {"K", "M", "B", "T", "Q"}

local million = 1000000

local function GetSuffix(Input)

local Base, Exponent = string.match(Input, "(%d+)^(%d+)") -- get the seperate numbers

Base, Exponent = tonumber(Base), tonumber(Exponent)

if not Base or not Exponent then return end



local Index = math.floor(million / 3) -- get the size of the number it is (hundred, thousand, million, etc.)

return (Base/10)..Suffixes[Index]--return the result

end



print(GetSuffix("10^6")) -- 10M
Log in to vote
0
Answered by
NGC4637 602 Moderation Voter
3 years ago

I'm super late to this, but I have thought of a way. I can't experiment on this method rn but do tell me if it works.

NumberValues can hold a "double precision floating point format" number aka. double number or float64 number. which has a number cap of 2^1024, much bigger than 2^63-1(int64 number cap)

so what I think would work is that you do this to the script:

 function onPlayerEntered(newPlayer)

    wait(.5)

    local stats = Instance.new("Folder")
    stats.Name = "leaderstats"
    stats.Parent = newPlayer

    local score = Instance.new("NumberValue")
    score.Name = "Blocks"
    score.Value = 10
    score.Parent = stats

    local score2 = Instance.new("NumberValue")
    score2.Name = "Multi"
    score2.Value = 2
    score2.Parent = stats

end



game.Players.ChildAdded:connect(onPlayerEntered)

then add a RemoteEvent in like ReplicatedStorage. Let's say you named it BigIntEvent.

and then a local script in StarterPlayerScripts with the following code:

local stats = game.Players.LocalPlayer:WaitForChild("leaderstats") -- waits until leaderstats is found.

stats.Blocks.Changed:Connect(function()
    local stat = "Blocks"
    game.ReplicatedStorage.BigIntEvent:FireServer(stat)
end)

stats.Multi.Changed:Connect(function()
    local stat = "Multi"
    game.ReplicatedStorage.BigIntEvent:FireServer(stat)
end)

then in ServerScriptService, add a script that says:

game.ReplicatedStorage.BigIntEvent.OnServerEvent:Connect(function(player,stat)
    if stat = "Blocks" then
        local Blocks = player.leaderstats.Blocks
        local value1 = math.clamp(Blocks.Value, 10, 1e303) -- clamps the number between 10 and 1 centillion to prevent weird stuff
        local value2 = math.round(value1) -- rounds the number to the closest integer so it don't have decimals
        Blocks.Value = value2 -- updates the value of the stat that wants to be changed
    elseif stat = "Multi" then
        local Multi = player.leaderstats.Multi
        local value1 = math.clamp(Multi.Value, 2, 1e303)
        local value2 = math.round(value1) 
        Multi.Value = value2
    end
end)

i hope this works ._.

0
hype! i tested it because tests are over and it bloody worked NGC4637 602 — 3y

Answer this question