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:
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)
function typed(player, text)
local folder = player:FindFirstChild("user")
folder:FindFirstChild("ID").Value = text
end
script.Parent.RemoteEvent.OnServerEvent:Connect(typed)
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.