Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

DataStore Isn't Loading Into Another Game Properly?

Asked by 5 years ago

Hello,

[SUBJECT]: Me and my dev team are making a 2-game based DataStore system, basically where one game that creates all the Data and sets the Data (aka, the Loading Menu), then loads into the other game to Async the data from the Menu (aka, the Park).

[ERROR]: Basically, I honestly don't know what the error is, but all I know is from using an in-game explorer or checking the output.

[MENU DATASTORE]:


local Player local DataVersion = "Version 3" game.Players.PlayerAdded:connect(function(NPlayer) Player = game:GetService('Players').LocalPlayer --local as = tostring(NPlayer) repeat wait() until Player.Character local vs = script:WaitForChild("Inventory"):clone() --local ui = script:WaitForChild('BillboardGui'):Clone() vs.Name = NPlayer.UserId vs.Parent = NPlayer --ui.Parent = workspace[as].UpperTorso NPlayer:LoadCharacter() local Stats = vs:GetChildren() local S1 = {} for i=1,#Stats do local n = Stats[i].Name S1[n] = Stats[i].Value end if NPlayer.Name ~= "Player" then local DataStore = game:GetService("DataStoreService"):GetDataStore(DataVersion,NPlayer.UserId) if DataStore:GetAsync("Stats") == nil then DataStore:SetAsync("Stats", S1) end S1 = DataStore:GetAsync("Stats") end local vv = vs:GetChildren() for i=1,#vv do local n = vv[i].Name if S1[n] ~= nil then vv[i].Value = S1[n] end end --[[while wait() do if not Player.Character.UpperTorso:FindFirstChild('BillboardGui') then ui.Parent = workspace[as].UpperTorso end end--]] end) game.Players.PlayerRemoving:connect(function(p) local DataStore = game:GetService("DataStoreService"):GetDataStore(DataVersion,p.UserId) local Stats = p:FindFirstChild(""..p.UserId..""):GetChildren() local S1 = {} for i=1,#Stats do local n = Stats[i].Name S1[n] = Stats[i].Value end DataStore:SetAsync("Stats",S1) end) --[[game.ReplicatedStorage.Events.SaveData.OnServerEvent:connect(function(SaveData) local DataStore = game:GetService("DataStoreService"):GetDataStore(DataVersion,Player.UserId) local Stats = Player:FindFirstChild(""..Player.UserId..""):GetChildren() local s1 = game.ReplicatedStorage.DataInfo.Data print'saving data' for i=1,#Stats do local n = Stats[i].Name s1[n] = Stats[i].Value end DataStore:SetAsync("Stats",s1) print'saved data' end)--]]

[PARK DATASTORE]


local Player local DataVersion = "Version 3" game.Players.PlayerAdded:connect(function(NPlayer) Player = game:GetService('Players').LocalPlayer --local as = tostring(NPlayer) repeat wait() until Player.Character local vs = script:WaitForChild("Inventory"):clone() --local ui = script:WaitForChild('BillboardGui'):Clone() vs.Name = NPlayer.UserId vs.Parent = NPlayer --ui.Parent = workspace[as].UpperTorso NPlayer:LoadCharacter() local Stats = vs:GetChildren() local S1 = {} for i=1,#Stats do local n = Stats[i].Name S1[n] = Stats[i].Value end if NPlayer.Name ~= "Player" then local DataStore = game:GetService("DataStoreService"):GetDataStore(DataVersion,NPlayer.UserId) if DataStore:GetAsync("Stats") == nil then DataStore:SetAsync("Stats", S1) end S1 = DataStore:GetAsync("Stats") end local vv = vs:GetChildren() for i=1,#vv do local n = vv[i].Name if S1[n] ~= nil then vv[i].Value = S1[n] end end --[[while wait() do if not Player.Character.UpperTorso:FindFirstChild('BillboardGui') then ui.Parent = workspace[as].UpperTorso end end--]] end) game.Players.PlayerRemoving:connect(function(p) local DataStore = game:GetService("DataStoreService"):GetDataStore(DataVersion,p.UserId) local Stats = p:FindFirstChild(""..p.UserId..""):GetChildren() local S1 = {} for i=1,#Stats do local n = Stats[i].Name S1[n] = Stats[i].Value end DataStore:SetAsync("Stats",S1) end)

If you can help, please respond on here, or contact me on Discord. Discord: Resplendid#2571

0
First of all, the "games" need to be places in ONE GAME. You can't make a datastore for one game and then go to another and recall that data. It has to be in the same game. Stephenthefox 94 — 5y
0
by reading what you want to do with 2 games, you could just make starter place in your game as LoadPlace and the other place as the main game as Park. Datastores are synced and shared over a whole game, so it's likely the same you're asking, just that making 2 games that have 1 function each other doesn't make sense, you should make 2 places inside one game! SulaymanArafat 230 — 5y

Answer this question