#Roblox Api scripts wont work

8 messages · Page 1 of 1 (latest)

clear kraken
#

I have no clue why doesnt it work, no errors and eveyrthing seems right

viral wren
#

you are only returning playerStore:GetAsync(), not making a variable for this

clear kraken
viral wren
#

Alright I think there's some misinformation here so I'll give you a quick rundown on how datastores work

#

First off, DataStoreService:GetDatastore() should be a constant variable

#

Think about it like a table that stores all the information saved to it. Add a variable to the top of your script with ```lua
local BeliDataStore = DataStoreService:GetDataStore("Your data store name here, can be anything")

#

Now, inside of your PlayerAdded function add this:

local PlayerData

local setSuccess, errorMessage = pcall(function()
    PlayerData = BeliDataStore:GetAsync(player.UserID)
end)
#

How it works:

  • The BeliDataStore is simply the name of the datastore saved to roblox's servers
  • Now, to get the data associated with a player we must do this: BeliDataStore:GetAsync(player.UserID). This retrieves the data saved to the players UserID from the DataStore