Datastore question!

Hello! I’m confused about something with datastores, i feel stupid for asking this question but i cant find a straight answer anywhere and hoping someone can help.

First off, i know how datastores work, and i use them. However, i am sick of having to constantly send all of the data through the teleport within a game(even indexed in a table and sent through the tele), when going to a different place in the game universe. So i guess my question is: I think i heard somewhere about not needing to send a games datastore data through the teleport, and i’m wondering how exactly i call the data from the game instead of the place? Another detail i should mention in my experimentation… i have a copy of the datastore script in the other place/places, and i’m wondering if that is correct for what i am trying to do. Can anyone please help me? THANKS! :slight_smile:

2 Likes

If you are trying to send data in-between places to places, I would try looking at the new Messaging Service

1 Like

Assuming all the places you want with the connected Datastores are in the game game/universe all you have to do to retrieve the data is call the same datastore name. For example:

Place 1:

game.Players.PlayerAdded:Connect(function(Player)
    local DataStore = game:GetService("DataStoreService"):GetDataStore("NameHere")
    local PlayerData = DataStore:GetAsync(Player.UserId)
end)

Place 2:

game.Players.PlayerAdded:Connect(function(Player)
    local DataStore = game:GetService("DataStoreService"):GetDataStore("NameHere")
    local PlayerData = DataStore:GetAsync(Player.UserId)
end)

In this case above it would be the exact same data which is stored in the PlayerData Variable.

From there you can simply pull data normally from either place and you will get the same data which you stored assuming its been saved.

So say for example I level up on Place 1, leave and go to Place 2. It would then pull from the same datastore which just saved in Place 1 and load into Place 2.

4 Likes

Thankyou! I was really just being a complete idiot lol. It is easier and more straightforward than i thought

No worries haha! Be sure to mark the answer as a solution assuming it works. If it does not feel free to reply to this and I will try to help you further.