So I made a game: https://web.roblox.com/games/4916966006/Island-Hunter-Simulator-TEST?refPageId=9286e993-bd6c-4b90-811f-fffa7f488c3d
But there is no autosave.
So I tried to make an autosave and it didn't work, please check the script for me, thank you:
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local coins = Instance.new("IntValue")
coins.Name = "Coins"
coins.Parent = leaderstats
local data
local success, errormessage = pcall(function()
data = myDataStore:GetAsync(player.UserId.."-coins")
end)
if success then
coins.Value = data
else
print("There was an error whilst getting your data")
warn(errormessage)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, errormessage = pcall(function()
myDataStore:SetAsync(player.UserId"-coins", player.leaderstats.Coins.Value)
end)
if success then
print("Player data successfully saved")
else
print("There was an error when saving data")
warn(errormessage)
end
end

7 comments
Are there any errors that come?
no, there are no error message or anything in the output, but it still doesn't autosave
You have a pcall, what comes from that?
Or maybe I can test this other script I've made just in case:
Seems fine to me
Did you forget the end) for the player removing function?
No, I didn't forget any end)