You can use DatastoreService and it will save the numbers, Here is an simple example.
local DSS = game:GetService("DataStoreService")
Now we have the service, Now we need to get the datastore.
local DS = DSS:GetDataStore("name")
Now we have the datastore, You can replace name with any name that you like. Now we need to set the datastore to the number.
local number = 92992
pcall(function()
DS:SetAsync("name",92992 or number)
end)
We make a variable called "number" that is just a number. In the first argument, You put the name that you set in the part where you got the datastore in my case it's "name". Now in the second argument, you can either put the number right away or just put a variable. We also used a pcall which what pcall does is whatever the code is inside the function it doesn't break the whole script. Now for when you want to get the number saved in the datastore.
local realNumber
pcall(function()
realNumber = DS:GetAsync("name")
end)
Now we made a variable named realNumber which is the real number that you saved. Now we have another pcall I have already explained what pcall is so I'll move on to the next line that I didn't explain. So now we set realNumber to the number that is saved and the only argument we have is the name, In my case the name is "name" and that's all!
If you want to set a unique one for each user then you can replace the "name" in :GetAsync() and :SetAsync() to player.UserId. Don't do that in the :GetDataStore() part though.
NOTE: Make sure API services are turned on through game settings in roblox studio or from the game configure page in the roblox website.
Hope I helped and have a good day!
4 comments
Thank you for the reply but I think you have miss understood my original question, I am able to save the numbers, The problem is the time is recorded locally as it's more accurate, But now i have to move that number that's stored locally over to the server side in order for my DataStore to be able to read the time set.
Oh
Just use a RemoteEvent!
Yes i know but the way i was thinking of doing it with remote event seemed a bit over complicated is all, so i was asking for ways i could do it, I'll just go with how i thought of doing it i guess.