How i do load player in the last location

How i do load player in the last location

How to make my code load the player in the last location he was? can someone help me with that please

Code

local event = game.ReplicatedStorage.ChangeChar

event.OnServerEvent:Connect(function(player,model)

local Char = model:Clone()

local Pos = player.Character:GetPrimaryPartCFrame()

player.Character:Destroy()

player.Character = Char

Char.Parent = workspace

Char:SetPrimaryPartCFrame(Pos)

end)
1 Like

I have a button to do (loadplayer) and in the last location that I am I want to press it and appear where the player is

is your new character model not spawning in the right position??

1 Like

Nvm i did a save position system with datastore and all is working lol thanks you guys :smiley:

if you’re still using that code I recommend you just doing PlayerObject:LoadCharacter() which reduces everything to one line of code.

1 Like

Thanks you! Tomorrow I’ll test how that works.