PLS HELP
Code
local dss = game:GetService("DataStoreService") local sv = dss:GetDataStore("Save1") game.Players.PlayerAdded:Connect(function(plr) for i,v in pairs(game.Workspace.Teleports:GetChildren()) do local tp = v.Bought local data local succ, err = pcall(function() data = sv:GetAsync(plr.UserId, v.Bought.Value) end) if succ then tp.Value = data print("Succ") end end end) for i,v in pairs(game.Workspace.Teleports:GetChildren()) do game.Players.PlayerRemoving:Connect(function(plr) local data = v.Bought.Value local succ,err = pcall(function() sv:SetAsync(plr.UserId.."_portal", v.Bought.Value) end) if succ then print("Data Saved") else print("Error Data") warn(err) end end) end
Hello, I think I have identified the problem. I dont understand why you do data saving in this way, will only work on single player game, but thats your bussiness I guess. The problem was you were getting a sync from player.UserId
but you were saving data like player.UserId_portal
. I fixed the code for you. I recommend you to not copy code from internet and write it all yourself, because I cant imagine how you could make this error in other way.
local dss = game:GetService("DataStoreService") local sv = dss:GetDataStore("Save1") game.Players.PlayerAdded:Connect(function(plr) for i,v in pairs(game.Workspace.Teleports:GetChildren()) do local tp = v.Bought local data local succ, err = pcall(function() data = sv:GetAsync(plr.UserId, v.Bought.Value) end) if succ then tp.Value = data print("Succ") end end end) for i,v in pairs(game.Workspace.Teleports:GetChildren()) do game.Players.PlayerRemoving:Connect(function(plr) local data = v.Bought.Value local succ,err = pcall(function() sv:SetAsync(plr.UserId, v.Bought.Value) end) if succ then print("Data Saved") else print("Error Data") warn(err) end end) end
Here is the fixed code. I wish you good luck in future with scripting, and I hope this helped.