Hi Im trying to break down this script that I found on youtube and im confused about one part and its this part GetAsync("User-"..player.UserId) could someone please also explain what "Waters" is equal
here is the full script if you need it
local DataStoreService = game:GetService("DataStoreService") local collected = DataStoreService:GetDataStore("collected") local ReplicatedStorage = game:GetService("ReplicatedStorage") local WaterList = ReplicatedStorage:WaitForChild("Waterbottles") game.Players.PlayerAdded:Connect(function(player) local WaterCollected = Instance.new("Folder",player) WaterCollected.Name = "WaterGettingColder" local success, errormessage = pcall(function() local water = collected:GetAsync("User-"..player.UserId) if water then for i, v in pairs(water) do local waterfound = WaterList:FindFirstChild(v) if waterfound then waterfound:Clone().Parent = WaterCollected end end end end) end) game.Players.PlayerRemoving:Connect(function(player) local success, errormessage = pcall(function() local collectedsave = {} for i, waters in pairs(player.WatereCollect:GetChildren()) do if waters then table.insert(collectedsave,waters.Name) end end collected:SetAsync("User-"..player.UserId,collectedsave) end) end) game:BindToClose(function(player) local success, errormessage = pcall(function() local collectedsave = {} for i, waters in pairs(player.WatereCollect:GetChildren()) do if waters then table.insert(collectedsave,waters.Name) end end collected:SetAsync("User-"..player.UserId,collectedsave) end) end)
:GetAsync is something that saves your entire progress, It is important for some games which wanted to make sure you have same value as your past value after you leave or took a break and change 'em and this thing will save up as your past value or current value. As result, your data saved in Datastore will saved unless it resets by renaming string or adding number in.
Adding Datastore be like this:
local number = 1 local datastore = game:GetService("DataStoreService") local data = datastore:GetDataStore("Test", number)
(Sorry, if this isn't problem you are facing)
:GetAsync is to do with getting a value like "Money" from a dataStore on Roblox. A dataStore is what saves data and basically lets you bring all your data on other games in your experience!
A example of this can be shown as:
local n = 1 --// Number local ds = game:GetService("DataStoreService") --// DataStore local result = ds:GetDataStore("D", n)
You can then use the data from the var "result". Hope this helps!