Datastore Tutorial (Reduce data loss!)

Should be ipairs(playerService:GetPlayers())

Also you forgot to link the place

2 Likes

Thanks, sorry I knew I’d forgotten something :joy:

Nice tutorial but please use task.wait() wait is outdated

3 Likes

You should do a tutorial on Profile Service. These types of data stores just reduce data loss, but what about REMOVING data loss?

2 Likes

I do like to use ProfileService, but this tutorial just focuses on Roblox’s default Datastore implementation. I agree Profile Service is more secure but sometimes it can take a while for data to load :slight_smile:

Using profileservice does not “remove data loss”, its only enemy is stuff like pet cloning via trading etc. not data loss


Generalized loops also work well, using ipairs or pairs does no difference.

3 Likes

ipairs is actually faster then pairs. ipairs should only be used when all objects that are being looped through are the same type.

because they are iterated, generalized pairs will either iterate pair or pairs if its a dictionary

also micro optimization is not good

edit

Edit: i hardly even call this optimization. you are only saving 0.01 seconds using ipairs

0.04	pairs
0.03	ipairs

code

local clock = os.clock
local function benchmark(benchmarks, times)
   for i,v in pairs(benchmarks) do
      local first = clock()
      for i = 1, times do
         v()
      end
      print(clock() - first, i)
   end
end
benchmark({
   ["pairs"] = function()
      for _,v in pairs({"hi", "mango"}) do
         v = nil
      end
   end,
   ipairs = function()
      for _,v in ipairs({"hi", "mango"}) do
         v = nil
      end
   end
}, 100000)

Just a quick suggestion when benchmarking, try to make the benchmark as light as possible to narrow in on what needs to be tested. I made a post about pairs and ipairs a while ago and benchmarked the two:

If we use that benchmark we can see the difference between the two is actually 0.000000000000014551915228 per iteration.

So you’re absolutely correct, it’s micro optimization; it’s just even more micro than what was shown.

2 Likes

I think they did, by using the DataId in the load function and checking it while saving.

2 Likes

It doesn’t save my data. :confused:
I followed everything I think the tutorial was not completed.

1 Like

You should try DataStore2 it’s easier to learn and doesn’t have any data loss (if used correctly)
Tutorial
Module

2 Likes

Did you get any error messages in the output?
Sorry for the late reply.

ProfileService works too and is more modern

2 Likes

I don’t even remember but I tried to follow the tutorial. It wasn’t easy, I had to cut somethings because I was not making an obby so I didn’t want to save the position of the player.

1 Like

I don’t know how to use it sadly.

2 Likes

Oh, I made a tutorial about it where you don’t have to set it up the repetitive way, unlike what YouTubers teach you to do:

I’m sorry about that, which part can you not get to work? :frowning:

Saving and giving the data I think. I had to remove a part of the script because I am not making an obby.

You may not be using it right.