I was trying to save data for a minigame and I get an error. Can anyone fix it? Thanks.
local DataStoreService = game:GetService("DataStoreService")
local experienceStore = DataStoreService:GetDataStore("MinigamePoints")
game.Players.PlayerAdded:Connect(function(plr)
local coins = Instance.new("IntValue",plr)
coins.Name = "Coins"
local key = "id-"..plr.UserId
local savedcoins = experienceStore:GetAsync(key)
if savedcoins then
coins = savedcoins[1]
else
local coinssaving = {coins.Value}
experienceStore:SetAsync(key,coins)
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local key = "id-"..plr.UserId
local save = {plr.Coins.Value}
experienceStore:SetAsync(key,save)
end)

2 comments
In DataStores you can save only player information, you can not save instances per se, you need to save the value of the instance. Usually people create tables in which they store all the necessary information of a player or save the "value" of the IntValue for example, not the instance itself.
line 17 {tostring(plr.Coins.Value)} (also reset your datastore) line 11 coinssaving = {tostring(coins.Value)} First reset your datastore to see if it fixed it.