✓ Accepted answer
To make this, we need to save the position in a DataStore. Here is a rough example.
local PositionStore = game:GetService("DataStoreService"):GetDataStore("PositionStore")
game:GetService("Players").PlayerAdded:Connect(function(player)
local Character = player.Character or player.CharacterAdded:Wait()
local Success, LastPosition = pcall(function()
return PositionStore:GetAsync(player.UserId)
end)
if Success and LastPosition ~= nil then
wait(1)
Character:MoveTo(Vector3.new(LastPosition.X, LastPosition.Y, LastPosition.Z)
end
end)
game:GetService("Players").PlayerRemoving:Connect(function(player)
local Character = player.Character
pcall(function()
local CurrentPosition = {
X = Character.HumanoidRootPart.Position.X,
Y = Character.HumanoidRootPart.Position.Y,
Z = Character.HumanoidRootPart.Position.Z
}
PositionStore:SetAsync(player.UserId, CurrentPosition)
end)
end)
1 comment
Save the location when they leave in a datastore, then load it when they join and teleport them to that point.