Datastore not loading values.`

No, the :AddItem() function gets the player and the pet sent to the function, and creates a viewport frame to parent to the players PlayerGui.

1 Like

Okay I think I fixed the duping issue. It was because of my BindToClose not being set up properly. Thank you to everyone who helped me!

No, that is inefficient. Instead wait until the server has done saving the data.

local function SaveData(player)
     -- save data
end

game:BindToClose(function()
     local saveJobs = #game.Players:GetPlayers()
     local completed = Instance.new("BindableEvent")

     for _, player in ipairs(game.Players:GetPlayers()) do
        coroutine.wrap(function()
                SaveData(player)
                saveJobs -= 1
        end)()

        if saveJobs == 0 then
              completed:Fire() -- we're done!
        end
     end 

    if saveJobs > 0 then 
        -- on going save jobs, wait until they are completed
        completed.Event:Wait()
    end
end)

nvm it’s duping again :frowning:
it was working for a bit but idk why it is duping again

Should I create a new topic since the original question has been answered?