I would expect this to save to datastore when the player leaves but it doesn't.

Data = game:GetService("DataStoreService"):GetDataStore("DataForDaMoon")
local Tycoon
game.Players.PlayerRemoving:Connect(function(Player)

    local playerData = {
        Money = Player.PlayerItems.MoneyMoon.Value,
        Placed = {}
    }

    if Player.leaderstats.SandboxSlot.Value == 'Sandbox1' then
        Tycoon = workspace.TestTycoon
    end

    for i, v in pairs(Tycoon.TestItems:GetChildren()) do
        if v:IsA('Model') then
            table.insert(playerData.Placed, {Name = v.Name, X = v.PrimaryPart.CFrame.x, Y = v.PrimaryPart.CFrame.y, Z = v.PrimaryPart.CFrame.z})
        end
    end

	Data:SetAsync(Player.UserId, playerData)
end)

2 comments

0

you are testing this with the roblox client and not studio, are you?

0

im testing with studio