Will this spawn multiple models in one space?
Asked by
7 years ago Edited 7 years ago
Hey guys, I have a question.
01 | local function setupPlayerData(player) |
02 | local data = DataStore 1 :GetAsync(player.UserId) |
04 | data = { Items = { } , Money = 0 , Experience = 0 } |
05 | DataStore 1 :SetAsync(player.UserId, sessionData [ player ] ) |
07 | sessionData [ player ] = data |
10 | game.Players.PlayerAdded:connect(setupPlayerData) |
12 | local function savePlayerData(player, playerItems) |
13 | for i, v in ipairs (workspace [ player.Name ] .itemHolder) do |
14 | sessionData [ player ] .Items [ v.Name ] = { |
15 | CFrameValues = { v:GetPrimaryPartCFrame().X, v:GetPrimaryPartCFrame().Y, v:GetPrimaryPartCFrame().Z, v:GetPrimaryPartCFrame():toEulerAnglesXYZ() } |
18 | DataStore 1 :SetAsync(player.UserId, sessionData [ player ] ) |
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:
1 | function loadPlayerData(player) |
2 | for i, v in ipairs (sessionData [ player ] [ Items ] ) do |
3 | local Base = workspace:WaitForChild( 'Baseplates' ):WaitForChild(player.Name) |
4 | local Item = game:GetService 'ReplicatedStorage' :WaitForChild( 'gameItems' ):FindFirstChild(sessionData [ player ] .Items [ v.Name ] ):Clone() |
5 | Item.Parent = Base:WaitForChild( "itemHolder" ) |
6 | Item.CFrame = CFrame.new(sessionData [ player ] .Items [ v.Name ] .CFrameValues) |
9 | 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.