Open source position saving system!

Hello guys i am happy to release my first opend-source system! This system is to save the position of the player by a point where you can go save and when you leave and rejoin you spawn at the point!

How to use?
It’s pretty simple! First you have to downbload the place file (can be found bellow) second you go on the studio and take a point (the green thing)! The third step is too go in the model and go to ValueFolder and save point value! Afther you can change the value to watever point it is (exemple the first point the second point etc.) BUT make sure to not give the same value to two point
2021-08-29 21-56-28
and now you can add how much point you want! (ALSO if the value of the point is 0 then all new player will spawn here if you dont want player to spawn here do not add a value). If you want to add a part put it in SavePointModel. AND also if you want you can change the proximity promp and everything you want! The teleport part is the part where the player teleport when they join. ALSO i forgot to say that this is completely free so you don’t have to give me any credit but if you do it would be cool!

Credit: Big thank to my friend nntom09 who helped me and @D0RYU who also helped me fixing the last bug!

here is the place if you find any bug send me a message to report it!: Position Saving - Roblox

16 Likes

Also if the place is not opend source tell me

2 Likes

and also if you have any question just send me a message

How could I create this so when the player leaves the server and rejoins their position is saved?

are you asking like you don’t nead to go to a save point and you just leave and the position is saved if yes then it’s a good question i could try to make it and if no just tell me what you are talking about

1 Like

i want so if you leave the game your current position is saved and when you rejoin you spawn in the same spot

umm idk how to do that’s but i can try if you want!

May I see the source code please? I’m on phone

interesting code
Seriously? This doesn’t actually do anything. You should instead be waiting until the datastore actually saves, not a set amount of time - and the code is messy.
There are four different scripts including a local script when this could be just one server script.

It’s a nice idea but you should work on readability and make it a little less all over the place. All throughout your code there are things like unnecessary newlines and bad practices like game.Workspace and game.Players.
Bad readability:
unnecessary newlines
Moreover, your use of comments is redundant. local function onPlayerJoin(player) is self-explanatory, I don’t need a comment that explains that it -- Runs when players join.

With your datastores, you are not wrapping functions in pcalls. This means if the functions break on Roblox’s end, your entire system will break. To be fair though, this isn’t that big of a deal considering it’s only saving player positions.
Another gripe about your datastore saving is that you’re only saving when players leave, not when they actually save. This would break if the server shuts down or similar, and if the player leaves to join a new server it might not save in time to load.

I think you should have another go at this and start from scratch. Try not using any local scripts and only use one script.

4 Likes

the data store is not made by be i taked a random data store because i wanted to focus on the sytem and not the other stuff, i don’t know what pcall is, i use different thing when i don’t know how to use them (like pcall)!

(ps it’s hard to learn to program when you are not english and they are litary no tutorial in my language)

Datastores are really important to get right as the last thing you want to lose is all of your progress in a game. However, they can error randomly on Roblox’s end and there is nothing you can do about it. This happens if the service is down, connection is lost, or any number of things. What you can do, is change how you handle it:

Pcalls (short for Protected Calls) allow the code to continue running even if it errors. A returned value called success is whether the code ran without erroring. If it errored, than we can repeat it until it doesn’t. Here’s an example:

DSS = game:GetService("DataStoreService")
DS = DSS:GetDataStore("Test")
local success, response
repeat
      success, response = pcall(function()
            DS:SetAsync("MyKey", "TestValue")
      end)
      if not success then
            task.wait(1)
      end
until success
1 Like