I've been working on finding out how to DataStore something not on the leaderstats, I came up with this but it does not save?
local DataStoreService = game:GetService("DataStoreService")
local save = DataStoreService:GetDataStore("save")
game.Players.PlayerAdded:Connect(function(player)
local DataValues = Instance.new("Folder")
DataValues.Name = "DataValues"
DataValues.Parent = player
local KoalaCounter = Instance.new("IntValue")
KoalaCounter.Name = "KoalaCounter"
KoalaCounter.Parent = DataValues
local Data2
local success, err = pcall(function()
Data2 = save:GetAsync(player.UserId.."-KoalaPoints", KoalaCounter.Value)
end)
if success then
KoalaCounter.Value = Data2
print("Success")
else
print("Error getting data")
warn(err)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, err = pcall(function()
save:SetAsync(player.UserId.."-KoalaPoints", player.DataValues.KoalaCounter.Value)
end)
if success then
print ("data saved")
else
print("There was an error")
warn(err)
end
end)
