EternityNum String Value doens't save in Data

Hello! I added EternityNum to my game recently, but I have some trouble using it for my data. In my data, I have 2 stats, one that requires EN (EternityNum) and one that doesn’t.
The thing is that I think this data model I used for a couple of years cannot support StringValues?
Here is my data:

local EN = require(game.ReplicatedStorage.EternityNum)
local Data = game:GetService("DataStoreService"):GetDataStore("Data")

game.Players.PlayerAdded:Connect(function(plr)
	local leaderstats = Instance.new("Folder", plr)
	leaderstats.Name = "leaderstats"
	
	local stat = Instance.new("Folder", plr)
	stat.Name = "stats"
	
	local Rarity = Instance.new("NumberValue", leaderstats)
	Rarity.Name = "Rarity"
	Rarity.Value = 1
	
	local luck = Instance.new("StringValue", stat)
	luck.Name = "Luck"
	local luckvalue = EN.convert(1)
	print(luckvalue)
	luck.Value = EN.toString(luckvalue)
	
	local dataload = Data:GetAsync(tostring(plr.UserId))
	
	if dataload then
		Rarity.Value = dataload[1]
		luck.Value = dataload[2]
	else
		Rarity.Value = 1
		luck.Value = EN.toString(luckvalue)
	end
end)


game.Players.PlayerRemoving:Connect(function(plr)
	Data:SetAsync(tostring(plr.UserId),{
		plr.leaderstats.Rarity.Value,
		plr.Stats.Luck.Value
	})
end)

And here is the error I get:
image

How can I fix that please?

Also, if you want here is a whole documentation about the EN module I use:

--[[
EN: A valid EternityNum Table
val: Any valid input that can be converted to an EternityNum Table

FUNCTIONS:
--// CHECK
	EN.IsNan(EN): boolean -> returns if the given value is NAN or not
	EN.IsInf(EN): boolean -> returns if the given value is INF or not
	EN.IsZero(EN): boolean -> returns if the given value is 0 or not

--// CONVERT
	EN.new(Sign, Layer, Exp): EN -> Directy create a new EternityNum Table :->: Sign * (10^^Layer)^Exp
	EN.fromNumber(number): EN -> Converts a number into an EternityNum Table
	EN.fromString(string): EN -> Converts a string into an EternityNum T able
	EN.fromScientific(string): EN -> Converts "XeY" into an EternityNum Table
	EN.fromDefaultStringFormat(string): EN -> Converts "X;Y" into an EternityNum Table
	EN.convert(val): EN -> Converts any valid input to an EternityNum Table
	
	EN.toNumber(EN): number -> Converts a EternityNum Table to an number
	EN.toString(EN): string -> Converts a EternityNum Table to an string ("X;Y")
	EN.toScientific(val): string -> Converts a value to an string ("XeY")
	EN.toLayerNotation(val, digits): string -> Converts a value to an string ("E(x)y")
	EN.toSuffix(val): string -> Converts a value to an suffix
	EN.short(val, digits): string -> Converts a value to an displayable string

--// BOOLEAN
	EN.eq(val1, val2): bool -> returns if val1 equals val2 (==)
	EN.le(val1, val2): bool -> returns if val1 is less then val2 (<)
	EN.me(val1, val2): bool -> returns if val1 is more then val2 (>)
	EN.leeq(val1, val2): bool -> returns if val1 is less or equal then val2 (<=)
	EN.meeq(val1, val2): bool -> returns if val1 is more or equal then val2 (>=)
	EN.bewteen(val, min, max): bool -> returns if val is between min and max

--// S CALCS
	EN.abs(val): EN -> returns the absolute value of val
	EN.neg(val): EN -> returns the negated value of val (-val)
	EN.recip(val): EN -> returns the reciprocal of val (1/val)
	EN.log10(val): EN -> returns the logarithm base 10 of val
	EN.abslog10(val): EN -> returns the logarithm base 10 of the absolute value of val :->: log10(abs(val))
	EN.exp(val): EN -> returns e^val 
    EN.pow10(val): EN -> returns 10^val
    EN.sqrt(val): EN -> returns the square root of val
    EN.gamma(val): EN -> returns (val - 1)!
    EN.fact(val): EN -> returns val!
    EN.correct(EN): EN -> error corrects an eternitynum (INTERNAL ONLY)
    
    --// USE FOR LEADERBOARDS
    EN.lbencode(val): number -> returns a number that can be stored in ordereddatastore
    EN.lbdecode(number): EN -> converts a lbecoded number back to an EternityNum Table
  
--// BIN CALCS
	EN.add(val1, val2): EN -> returns val1 + val2
	EN.sub(val1, val2): EN -> returns val1 - val2
	EN.mul(val1, val2): EN -> returns val1 * val2
	EN.div(val1, val2): EN -> returns val1 / val2
	EN.pow(val1, val2): EN -> returns val1 ^ val2
	EN.log(val, base): EN -> returns logarithm of val, if base is nil it will return log(val) (natural logarithm)
	EN.root(val1, val2): EN -> returns val2'th root of val1
	EN.rand(min, max): EN -> returns a random number between min and max
	EN.exporand(min, max): EN -> returns a random number between min and max
	EN.cmp(val1, val2): number -> 
		returns 0 if val1 == val2
		returns 1 if val1 > val2
		returns -1 if val1 < val2
	EN.cmpAbs(EN1, EN2): number -> returns cmp(abs(EN1),abs(EN2))
	EN.maxAbs(val1, val2): EN -> returns the max(abs(val1), abs(val2))
	
-- TO ADD:
	EN.min(val1, val2)
	EN.max(val1m val2)
]]

You see whenever ive used EN, I used DataStore2, it is more diverse and easier to handle and requires little to no expertise via its documentation, with DS2 something like this would not happen iirc

Okay, do you have any idea where I could learn more about DS2?

Yeah, search DataStore2 in the devforum, or go to DataStore2 which also has a documentation with a tutorial

1 Like

I can provide a ready made example when I reach home.

Sure! I’d love to! Thanks, I have all the time you need

1 Like

Well, I restarted roblox and apparently there’s no error??? And the script is working fine. Weird lol