Number values and int values dont accept long numbers

so im trying to make it so when you enter your discord ID into a value in the player then saves it to a datastore, but when I enter it it changes the number.

i enter 527468643613802517
it changes to this:
image

	local folder = player:FindFirstChild("user")
	folder:FindFirstChild("ID").Value = text
end

script.Parent.RemoteEvent.OnServerEvent:Connect(typed)

local script:

local player = game.Players.LocalPlayer

if player:FindFirstChild("user"):FindFirstChild("ID").Value ~= 0 then 
	script.Parent.Parent.Enabled = false
else
	script.Parent.Parent.Enabled = true
end

text.FocusLost:Connect(function(enterPressed)
	if enterPressed then
		if text.Text ~= nil then 
			print("Player pressed Enter")
			script.Parent.RemoteEvent:FireServer(text.Text)
		end
	end
end)

Just use a string value. And when you reference it in code, wrap it in tonumber

Thanks, didnt think of that one

1 Like

the only problem is, it changes it to “5.274686436138e+17” do i need tonumber?

Huh? It shouldn’t. Can I see your code where you set the value

1 Like

its the one above,

function typed(player, text)
	local folder = player:FindFirstChild("user")
	folder:FindFirstChild("ID").Value = text
end

script.Parent.RemoteEvent.OnServerEvent:Connect(typed)

Cna I see the code where you fire it to the server

thats also included above
its the last script i posted in my original post

Hmmm… it shouldnt do that. Do you have a screenshot or smth

screenshot of what?
im not sure what you need

Of the value being that. Cuz I don’t really know why it’s be doing that

image

i tried even wrapping the datastore in tonumber and it did the same thing

i just tried formatting it with %f, %i, %d and it removes the e+17 but still isnt the right number

Why on earth are you doing this? Both casting string to IEEE and IEEE to string is an expensive process. I’d only use __tostring on IEEE if it’s for formatting (displaying) and nothing else.

Please read the Lua 5.1 source code. __tostring on VM type "number" is basically C’s printf %.14g specifier not sure why you said it shouldn’t print in scientific notation.
It’s the IEEE 754 double precision floating point format so of course it’ll return in the e notation in certain format specifier. It’s literally represented in scientific notation (in this case, in binary). What do you expect?


To OP:
The "number" type in Roblox Luau is represented in the IEEE 754 double precision floating point format.
NumberValues internally store its value as doubles, same as the VM type "number".
Because there’s no int64_t VM type, IntValue casts doubles to int64_t therefore it suffers the same precision loss as IEEE double precision floating points but only accepts integers in the range of int64_t. Same with formatting if %i and %d.

If you can avoid floating point arithmetic, I can recommend StringValues and do not try to cast it to IEEE.

1 Like

oh ok. said this


cuz i was using string values for a game instead of int values and it worked fine like that

StringValues just do this,
image