The error is 11:57:58.555 - ServerScriptService.Script:48: bad argument #1 (Lua function expected), on the coroutine. Here is the script:
local DataStoreService = game:GetService("DataStoreService")
local save = DataStoreService:GetDataStore("save")
local players = game:GetService("Players")
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)
game:BindToClose(function()
for _, player in ipairs(players:GetPlayers()) do
coroutine.wrap(save)(player)
end
end)
