It saves the player's position when they leave then teleports them there when they rejoin, I honestly do not know what went wrong. It is probably with the datastore.
game.Players.PlayerAdded:connect(function(p)
pos = Instance.new("CFrameValue",p)
pos.Name = "position"
p.CharacterAdded:connect(function(c)
if game:GetService("DataStoreService"):GetDataStore("data1"):GetAsync(p.Name.."_pos") then
c.Torso.CFrame = game:GetService("DataStoreService"):GetDataStore("data1"):GetAsync(p.Name.."_pos")
end
end)
end)
game.Players.PlayerRemoving:connect(function(p)
game:GetService("DataStoreService"):GetDataStore("data1"):SetAsync(p.Name.."_pos",p.position.Value)
end)
while true do
for i,v in pairs(game.Players:GetChildren()) do
if v.Character:FindFirstChild("Torso") then
v.position.Value = v.Character.Torso.CFrame
end
end
wait()
end
