I did, now in the script it shows that there are 3 more, those that I told you.
Hover over the red lines and tell me what they say.
Ok, simple.
local DataStore = game:GetService("DataStoreService")
local store = DataStore:GetDataStore("PlayerCharacterInfo", "PlayerPosition") --don't change the name of the DataStore or all data on it will be reset
local positions = {}
local function WaitForRequestBudget(budgetType)
local request = pcall(function() return Enum.DataStoreRequestType[budgetType] end)
if not request then return end
if DataStore:GetRequestBudgetForRequestType(request) <= 0 then return end
return true
end
local function save(player)
if not WaitForRequestBudget("UpdateAsync") then
repeat task.wait(3) until WaitForRequestBudget("UpdateAsync")
end
xpcall(function()
store:UpdateAsync(tostring(player.UserId), function() return positions[player] end)
end, function() warn(string.format("Error while saving %s's position!", player.Name)) end)
positions[player] = nil
end
game.Players.PlayerAdded:Connect(function(player)
local position = pcall(function()
return store:GetAsync(tostring(player.UserId))
end)
if not position then return end
player.CharacterAdded:Once(function(character)
character:PivotTo(CFrame.new(position[1], position[2], position[3]))
character.HumanoidRootPart:GetPropertyChangedSignal("CFrame"):Connect(function()
positions[player] = {character:GetPivot()[1], character:GetPivot()[2], character:GetPivot()[3]}
end)
end)
end)
game.Players.PlayerRemoving:Connect(save)
game:BindToClose(function()
for _, v in game.Players:GetPlayers() do
task.spawn(save, v)
end
task.wait(15)
end)
Edited, should now be fixed. Just let me know of any errors.
It has like the same errors like before and the end))
Sorry about that, mobile typos.
Try it again, sorry if this is irritating.
No problem, thanks for trying to help btw, now it got no erros, I will go test it. Also how long does it take to save location so I can wait.
You just need to leave, that’s when it saves.
Okay, so I joined in game from Studio, then I left and it didn’t save the location.
Because in a past roblox studio update, clicking ‘stop’ no longer triggers Players.PlayerRemoving
, so to test it, go to ‘Test’ and start a new server. Then, if you want to leave, close the tab.
Those aren’t errors… They just show that the script is running.
Bruh, just forget about it. Lol.
Test and then fo to start and set 1 player?
Pretty much, I believe so.
Try it.
I tried it, it doesn’t work.
Hm alright. Run this in the command bar please.
print(game:GetService("DataStoreService"):GetDataStore("PlayerCharacterInfo", "PlayerPosition"):GetAsync("2203123161"))
It still doesn’t work. WEhat can i do?
…
I asked you to run the code in the command bar.
What does it print in the output?