local ServerStorage = game:GetService("ServerStorage")
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local DataStore2 = require(ServerStorage.Modules.DataStore2)
DataStore2.Combine("Data","LastPosition")
Players.PlayerAdded:Connect(function(player)
local character = player.Character or player.CharacterAdded:Wait()
local LastPosition = DataStore2("LastPosition",player)
if character:FindFirstChild("HumanoidRootPart") then
wait(1)
character.HumanoidRootPart.CFrame = CFrame.new(table.unpack(LastPosition:Get()))
end
end)
while true do
wait(5)
for i,v in pairs(Players:GetPlayers()) do
if v.Character then
local LastPosition = DataStore2("LastPosition",v)
if v.Character:FindFirstChild("HumanoidRootPart") then
LastPosition:Set({v.Character.HumanoidRootPart.CFrame:GetComponents()})
end
end
end
end
i think the problem is just the loading part cuz it do be saving the position
What I think you should do is save the position using {CFrame:GetComponents()} not only does it save the position but also the exact orientation of the HumanoidRootPart and you would load their CFrame using table.unpack(LastPosition:Get())
Players.PlayerAdded:Connect(function(player)
local character = player.Character or player.CharacterAdded:Wait()
local LastPosition = DataStore2("LastPosition",player)
if character:FindFirstChild("HumanoidRootPart") then
local Params = {
destination = CFrame.new(table.unpack(LastPosition:Get())),
faceAngle = 0,
freeze = false,
}
wait(1)
Teleport.Teleport(character.Humanoid, Params)
end
end)