How could i make a collectible system? (take the one from Isle as an example)

Im gonna try to explain this very simply, i have some values for each collectible inside a viewportframe (only the value thing matters, everything else works), when i click an object in workspace that has a script to enable that specific value it does get enabled. I want the states of the value to save for each player with datastore.

Problem is, the values dont save, they saved once, but every player was sharing the same datastore somehow (im kinda new to datastores), after i tried fixing it, it did not want to save no matter what i tried.

Ive already tried to use the name of the datastore as the id of the player it corresponds to, but it does not work… And i dont even know why!

If anyone could help me out it would be really helpful.

1 Like

It sounds like the issue is that you’re not associating the DataStore with each player’s unique UserId. To fix this:

  1. Use Player.UserId as the key for the DataStore. Example:
local dataStore = game:GetService("DataStoreService"):GetDataStore("YourDataStoreName")
local playerKey = "Player_" .. player.UserId
  1. Save and load data like this:
-- Save data
dataStore:SetAsync(playerKey, data)

-- Load data
local success, savedData = pcall(function()
    return dataStore:GetAsync(playerKey)
end)
  1. Make sure you are using Pcall to catch errors with datastores

If all players are sharing data, you might be using the same key for everyone. Check your implementation. Hope this helps!

2 Likes