What do i want to achieve? Well the title says it all. I would like to know how to save the players position and loading it when they rejoin. I mostly don’t know how to approach this task, so i though i would ask for help.
For reference, game like Rogue Lineage by Ragoozer save your location, and when you rejoin, it loads your character from spawn to the exact location of where you were before you left.
Should i save the CFrame to a table and load it back when the player joins the game? Should i save coordinates to a DataStore value?
Thanks for helping, hope i make my question clear!
Well here is a way I would go making it. And yes a good idea would be saving the player’s location by using the player’s HumanoidRootPart and getting the CFrame of it, and that will give the location of the current player, and if you try teleport the player’s HumanoidRootPart it will teleport the whole player. (note that the code maybe be not even working or doing something but its just a way to make you understand maybe a little better how CFrames work and the player)
-- // VARS
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character
local Root = Character:FindFirstChild("HumanoidRootPart")
-- // CODE
local CFrameTable = {}
local function GetPlayerCFrame()
table.insert(CFrameTable, Player.Name.."'s Position:"..Root.CFrame)
end)
I think this would save the CFrame only in the existing server. To make it work in all servers you can use DataStore and save Player’s Position in a value.