So I’ve created this datastore following a tutorial. I’ve never done datastores with tables before and for some odd reason it doesn’t work. I don’t get any errors in studio or in game but nothing saves. I’ve tried changing values locally in studio and on the server side in studio. I’ve also changed values in game using the /console but things just don’t seem to save. Any suggestions as to why this might be would be very helpful.
EDIT: This is a normal script in ServerScriptService
game.Players.PlayerAdded:Connect(function(player)
local PlayerGui = player:WaitForChild("PlayerGui")
local NPCS = PlayerGui:WaitForChild("NPCS")
local JohnValues = NPCS.John:WaitForChild("Values")
local JohnCurrentQuest = JohnValues.CurrentQuest -- This is an Int Value
local JohnCurrentTalkLine = JohnValues.CurrentTalkLine -- This is an Int Value
local ActiveQuest = JohnValues.ActiveQuest -- This is a Bool value
local NPCStats = NPCData:GetAsync(player.UserId)
if NPCStats ~= nil then
JohnCurrentQuest.Value = NPCStats[1]
JohnCurrentTalkLine.Value = NPCStats[2]
ActiveQuest.Value = NPCStats[3]
else
JohnCurrentQuest.Value = 0
JohnCurrentTalkLine = 0
ActiveQuest.Value = false
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local PlayerGui = player:WaitForChild("PlayerGui")
local NPCS = PlayerGui:WaitForChild("NPCS")
local JohnValues = NPCS.John:WaitForChild("Values")
local JohnCurrentQuest = JohnValues.CurrentQuest -- This is an Int Value
local JohnCurrentTalkLine = JohnValues.CurrentTalkLine -- This is an Int Value
local ActiveQuest = JohnValues.ActiveQuest -- This is a Bool value
local NPCSave = {}
table.insert(NPCSave, JohnCurrentQuest.Value)
table.insert(NPCSave, JohnCurrentTalkLine.Value)
table.insert(NPCSave, ActiveQuest.Value)
NPCData:SetAsync(player.UserId, NPCSave)
end)