Basically, when player clicks the part, the boolvalue of boughtAK is supposed to be true. And when player leaves, the value is supposed to be saved, but it's not saving, any help?
local DS = game:GetService("DataStoreService"):GetDataStore("Exp")
game.Players.PlayerAdded:Connect(function(player)
local boughtAK = Instance.new("BoolValue", player)
boughtAK.Name = "boughtAK"
workspace.Part.ClickDetector.MouseClick:Connect(function(clickPlayer)
clickPlayer.boughtAK.Value = true
end)
local stats = DS:GetAsync(player.UserId)
end)
game.Players.PlayerRemoving:Connect(function(player)
local allSaves = {}
table.insert(allSaves, player.boughtAK.Value)
DS:SetAsync(player.UserId, allSaves)
end)

3 comments
It will not work because you are not loading in the data.
Thanks @Soban06
You're most welcome.