Hey guys, I have a question.
local function setupPlayerData(player) local data = DataStore1:GetAsync(player.UserId) if not data then data = {Items = {}, Money = 0, Experience = 0} DataStore1:SetAsync(player.UserId, sessionData[player]) end sessionData[player] = data end game.Players.PlayerAdded:connect(setupPlayerData) local function savePlayerData(player, playerItems) for i, v in ipairs(workspace[player.Name].itemHolder) do sessionData[player].Items[v.Name] = { CFrameValues = {v:GetPrimaryPartCFrame().X, v:GetPrimaryPartCFrame().Y, v:GetPrimaryPartCFrame().Z, v:GetPrimaryPartCFrame():toEulerAnglesXYZ()} } end DataStore1:SetAsync(player.UserId, sessionData[player]) end
I have a three by three grid that saves every sixty seconds (or, one minute.) Once the game saves twice with a part unmoved, on the next game join, will there be three parts in the same location?
If so, how would I prevent that?
Baseplate loading code:
function loadPlayerData(player) for i, v in ipairs(sessionData[player][Items]) do local Base = workspace:WaitForChild('Baseplates'):WaitForChild(player.Name) local Item = game:GetService'ReplicatedStorage':WaitForChild('gameItems'):FindFirstChild(sessionData[player].Items[v.Name]):Clone() Item.Parent = Base:WaitForChild("itemHolder") Item.CFrame = CFrame.new(sessionData[player].Items[v.Name].CFrameValues) end end game.Players.PlayerAdded:connect(loadPlayerData)
There might be errors I'm not aware of. I'll fix these errors while someone comes up with an answer.
Yes. It will. EDIT: Add this
game.Players.LocalPlayer.modelSpawned = true
Add a part of the script that would detect if modelSpawed is true. If it is then probably do a return end) . Also set modelSpawned to false when the player first joined.