Can someone help me create a script that spawns the player where they were last time in the game? If the players position is 6,2,-9, and the player rejoins. They are back at 6,2, -9. Please tell me how to make script that does that or give me the code.
local d = game:GetService("DataStoreService"):GetDataStore("Positions")
game.Players.PlayerAdded:Connect(function(p)
if d:GetAsync(p.UserId) then
for _, v in pairs(d:GetAsync(p.UserId)) do
wait(5)
local x = d:GetAsync(p.UserId)[1]
local y = d:GetAsync(p.UserId)[2]
local z = d:GetAsync(p.UserId)[3]
local h = p.Character:WaitForChild("Humanoid") -- make sure char loaded
p.Character.HumanoidRootPart.Position = Vector3.new(x,y,z)
end
end
end)
game.Players.PlayerRemoving:Connect(function(p)
local hrp = p.Character.HumanoidRootPart.Position
d:SetAsync(p.UserId,{hrp.X,hrp.Y,hrp.Z})
end)
game:BindToClose(function()
for _, v in pairs(game.Players:GetChildren()) do
local x = v.Character.HumanoidRootPart.Position.X
local y = v.Character.HumanoidRootPart.Position.Y
local z = v.Character.HumanoidRootPart.Position.Z
d:SetAsync(v.UserId,{x,y,z})
end
end)
even the script above doesnt work.

1 comment
thanks for copying my old code.