So I"m making a system where in each subplace of an experience there’s a note that the player must interact with. Once all five notes across each of the five subplaces have been found, a door is opened in the starting place, which does not have its own note. Updating the value of the datastore table value between each place works fine, but I notice that for whatever reason only the most recently saved table value is recorded. Here’s my code:
local notegui = game.ServerStorage:WaitForChild("NoteGUI")
local datastoreserv = game:GetService("DataStoreService")
local data = datastoreserv:GetDataStore("crossdata")
script.Parent.Triggered:Connect(function(player)
if notegui.Parent == game.ServerStorage then
notegui.Parent = player.PlayerGui
local trueorfalse = data:GetAsync(player.UserId)
if trueorfalse.grave == 0 or trueorfalse.grave == nil then
print(trueorfalse.grave)
data:SetAsync(player.UserId, {
grave = 1;
})
end
end
end)
game.Players.PlayerAdded:Connect(function(player)
print(data:GetAsync(player.UserId).grave)
end)
This section of code is in a script within the proximityprompt within the physical note part. There’s one per subplace. The only thing different between them is the name of the table value.
Now here’s the script in the starting place, where all five of these values are checked:
local datastore = game:GetService("DataStoreService")
local data = datastore:GetDataStore("crossdata")
game.Players.PlayerAdded:Connect(function(player)
local datataken = data:GetAsync(player.UserId)
print(datataken.thingy1)
print(datataken.thing2)
print(datataken.grave)
print(datataken.sea)
print(datataken.beach)
print(datataken.arch)
print(datataken.castle)
end)
game.Players.PlayerAdded:Connect(function(player)
local listofnotevals = data:GetAsync(player.UserId)
if data:GetAsync(player.UserId).grave == 1 and data:GetAsync(player.UserId).arch == 1 and data:GetAsync(player.UserId).castle == 1 and data:GetAsync(player.UserId).sea == 1 and data:GetAsync(player.UserId).beach == 1 then
workspace.note.note_texture.Enabled = true
workspace.note.note_prompt.Enabled = true
else
workspace.note.note_texture.Enabled = false
workspace.note.note_prompt.Enabled = false
end
end)
After I interacted with all of the notes in their places - which should set the values of all of these to 1, (i decided to use integers instead of booleans if you hadn’t already noticed) and joined the starting place, every single one of these values - except the most recently updated one - printed as nil. Am I using SetAsync wrong? Please help me out.