Now I have tried doing this and it is part of a data storage. However, I have no idea how to get player position when they leave. Here is what I tried:
game.Players.PlayerRemoving:Connect(function(player) game.Players:FindFirstChild(player.Name).Location.X.Value = game.Workspace:FindFirstChild(player.Name).HumanoidRootPart.Position.X game.Players:FindFirstChild(player.Name).Location.Y.Value = game.Workspace:FindFirstChild(player.Name).HumanoidRootPart.Position.Y game.Players:FindFirstChild(player.Name).Location.Z.Value = game.Workspace:FindFirstChild(player.Name).HumanoidRootPart.Position.Z end)
These are coordinates for the player when they leave which I hoped would get their location when they leave. Obviously, it does not work. How would I do this?
local Players = game:GetService("Players") local function onCharacterAdded(character) end local function onCharacterRemoving(character) print(character.HumanoidRootPart.Position.X) print(character.HumanoidRootPart.Position.Y) print(character.HumanoidRootPart.Position.Z) end local function onPlayerAdded(player) player.CharacterAdded:Connect(onCharacterAdded) player.CharacterRemoving:Connect(onCharacterRemoving) end Players.PlayerAdded:Connect(onPlayerAdded)
This script appears to function perfectly. Try using this instead of directly doing game.Players.PlayerRemoving?
what i'd use is datastores to save and load positions. Try this it might work, I am very lazy to test it out but it just might work / give you a rough idea on how to save the players position when they leave.
local data = game:GetService('DataStoreService'):GetDataStore('data') game.Players.PlayerAdded:Connect(function(p) local fetchedD = data:GetAsync(p.UserId) -- loading. if fetchedD ~= nil then for _, v in pairs(fetchedD) do if v then p.Character.HumanoidRootPart.Position = Vector3.new(fetchedD[1],fetchedD[2],fetchedD[3]) else print('no data') end end end end) game.Players.PlayerRemoving:Connect(function(p) function save() local table = {} -- saving all the data. local pos = p.Character.HumanoidRootPart.Position table.Insert(table,pos.X) table.Insert(table,pos.Y) table.Insert(table,pos.Z) end save() end) game:BindToClose(function() save() end)
So this is my rough assumption, there might be an error where there is BindToClose but other than that, this script should work.
Remember if this helped at all, click the accept button, thanks, bye C: