You could do this way more simplistic, and hence items shouldn’t be placed instantly, directly saving to the DataStore would be efficient in my case.
My Approach
local DataStoreService = game:GetService("DataStoreService")
local PlotItemPositions = DataStoreService:GetDataStore("PlotItemPositions")
function onPlayerJoined(player)
local userId = player.UserId
local position = PlotItemPositions:GetAsync(userId)
if position then
-- Place the item in its saved position
local item = game.Workspace.Item
item.Position = position
end
end
game.Players.PlayerAdded:Connect(onPlayerJoined)
-- Also call onPlayerJoined for any players already in the game
for _, player in ipairs(game.Players:GetPlayers()) do
onPlayerJoined(player)
end