Hello, so this code saves the location when a player leaves so the question is how do I make a script that teleports them to their last location when they're joining?
local DataStore = game:GetService("DataStoreService"):GetDataStore("test")
wait(1)
print(DataStore:GetAsync("last"))
print(DataStore:GetAsync("time"))
local lastPos = Vector3.new(0,0,0)
game.Players.PlayerAdded:connect(function(plr)
plr.CharacterRemoving:Connect(function(char)
lastPos = char.HumanoidRootPart.Position
end)
end)
game.Players.PlayerRemoving:Connect(function(plr)
DataStore:SetAsync("last",tostring(lastPos))
DataStore:SetAsync("time",tostring(tick()))
end)
game:BindToClose(function()
wait(3)
end)

4 comments
try this: local stats = game.Players.LocalPlayer:WaitForChild("leaderstats"). This will award the XP to the localplayer's leaderstats
Edit your code and use the blue Lua symbol to generate a block where you can put your code inside. This will make your code formatted so everyone can see it clearly.
BloxRoxe i'm going to try that now ty! chomboghai ty changed it :D
Tysm BloxRoxe it's working.. im so dumb that i didn't use LocalPlayer xD