I have this story based game and I wanted to make a loads/save system, where you can overwrite, create and load saves of their story progression. I’ve finished practically everything, hovewer, I use a datastore to move the player’s data, and it is not loading anything, I even set up a discord webhook wich sends the player’s data when they leave and join the game, but it says zamd157 joined the game, Data: [null] ([null] is the table converted into a JSON string). Some important info: the places are in the same game, they are 1 player servers, and studio access to api services are on both places. So here’s my scripts:
-- in the starting place wich is the main menu
local DataStoreService = game:GetService("DataStoreService")
local LoadDataStore = DataStoreService:GetDataStore("crossadata")
local HttpService = game:GetService("HttpService")
local TPService = game:GetService("TeleportService")
local PlaceId = 5641534502
local CreateLoad = game.ReplicatedStorage:WaitForChild("Events"):WaitForChild("CreateLoad")
local LoadSave = game.ReplicatedStorage.Events.LoadSave
game.Players.PlayerAdded:Connect(function(player)
local key = player.UserId
local savedData
pcall(function()
savedData = HttpService:JSONDecode(LoadDataStore:GetAsync(key))
end)
if savedData ~= nil then
print("not nil")
print(savedData[1])
for i,v in pairs(savedData) do
print("creating")
if v:IsA("Folder") then
print("folder")
v.Parent = player
elseif v:IsA("IntValue") then
print("intvalue")
print(v.Name)
v.Parent = player
end
end
end
end)
CreateLoad.OnServerEvent:Connect(function(player,loadNumber)
if player:FindFirstChild("Load"..loadNumber) then
player["Load"..loadNumber]:Destroy()
end
local folder = Instance.new("Folder")
folder.Name = "Load"..loadNumber
folder.Parent = player
local position = Instance.new("CFrameValue")
position.Name = "Position"
position.Parent = folder
local phase = Instance.new("StringValue")
phase.Name = "Phase"
phase.Parent = folder
phase.Value = "Not started"
local currentLoad = Instance.new("IntValue")
currentLoad.Name = "CurrentLoad"
currentLoad.Parent = folder
for i,v in ipairs(folder:GetChildren()) do
end
TPService:Teleport(PlaceId,player)
print("tped")
end)
LoadSave.OnServerEvent:Connect(function(player)
TPService:Teleport(PlaceId,player)
end)
game.Players.PlayerRemoving:Connect(function(player)
print("obama")
local key = player.UserId
local folders = {}
for i,v in pairs(player:GetChildren()) do
if string.find(v.Name,"Load") then
table.insert(folders,#folders+1,v)
end
end
LoadDataStore:SetAsync(key,HttpService:JSONEncode(folders))
end)
-- in the actual story place
local DataStore = game:GetService("DataStoreService")
local TableDataStore = DataStore:GetDataStore("crossadata")
local HttpService = game:GetService("HttpService")
local RS = game.ReplicatedStorage
local Level = game.ReplicatedStorage:WaitForChild("Level")
local PhaseValue = Level.Phase
local Position = Level.Position
local Values = game.Workspace:WaitForChild("Values")
local currentLoad = Values:WaitForChild("CurrentLoad")
--[[
{
Load0 = {
CurrentLoad
PositionCFrame
Phase
}
}
]]
game.Players.PlayerAdded:Connect(function(player)
local data
local key = player.UserId
pcall(function()
data = HttpService:JSONDecode(TableDataStore:GetAsync(key))
end)
if data ~= nil then
print("not nil")
print(data[1])
for i,v in pairs(data) do
print(v.Name)
if v:IsA("Folder") then
print(v.Name)
for i,v in pairs(v:GetChildren()) do
print(v.Name.." "..v.Value)
end
print("load")
v.Parent = player
RS.Level.Phase.Value = player["Load"..currentLoad].Phase.Value
RS.Level.Position.Value = player["Load"..currentLoad].Phase.Value
end
end
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local message = HttpService:JSONEncode(
)
local key = player.UserId
local folders = {}
for i,v in pairs(player:GetChildren()) do
if string.find(v.Name,"Load") then
table.insert(folders,#folders+1,v)
end
end
TableDataStore:SetAsync(key,HttpService:JSONEncode(folders))
end)
Any help is appreciated