It doesn’t say something. So what do I do?
Are you sure?
Try walking around, it SHOULD print something.
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 HTTPService = game:GetService("HTTPService")
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 HTTPService:JSONEncode(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 HTTPService:JSONDecode(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]))
end)
player.CharacterAdded:Connect(function(character)
character.HumanoidRootPart:GetPropertyChangedSignal("CFrame"):Connect(function()
positions[player] = {character:GetPivot()[1], character:GetPivot()[2], character:GetPivot()[3]}
print("Debug:", table.concat(positions[player], ", ")
end)
end)
end)
game.Players.PlayerRemoving:Connect(save)
game:BindToClose(function()
for _, v in game.Players:GetPlayers() do
task.spawn(save, v)
print(string.format("Saving %s's data!", v.Name))
end
task.wait(15)
end)
It doesn;t say something I didn’t know save location is that hard.
It isn’t that hard. It’s the setup that is hard.
So what do we do now? It doesn’t work.
Are you SURE nothing prints?
Do you know how the output actually works?
Yeah, I am sure it prints nothing.
Walk around and show me the output.
I’m going to go to bed now. Sorry that I couldn’t help. It’s 9pm here.
Okay, good night btw it’s hard to find the print because it spams errors from smth else.