Great! It's fantastic that the leaderstats are now showing "Coins: 0" and "Gems: 0". That confirms the script is correctly creating the leaderstats values, and the leaderboard display is working!
The new error:
DataStoreService: StudioAccessToApisNotAllowed: Studio access to APIs is not allowed. API: GetAsync, Data Store: GemsStore
Meaning: This error is happening because you are running the game in Roblox Studio, and Studio, by default, prevents scripts from accessing Data Stores for security reasons.
Solution: You need to explicitly enable API access in your game's settings within Roblox Studio.
Here's how:
- In Roblox Studio, make sure you are on the Home tab.
- Click on Game Settings (it looks like a gear icon).
- In the Game Settings window, go to the Security tab.
- Look for an option that says "Enable Studio Access to API Services" (or similar wording, sometimes it's just "Allow Studio Access to API Services").
- Check the box next to this option.
- Click the Save button at the bottom right.
Now, when you run your game in Studio, it should be able to access the Data Stores (GetAsync and SetAsync) without throwing that error.
Why did this happen now?
Before, the DataStore error was You must publish this place.... Once you published, the DataStore could potentially be accessed, but Studio still blocked it until you enabled the security setting.
Fix this security setting, run the game again, and that error should go away. The leaderstats showing 0 is the correct behavior since you likely don't have any saved data for your player yet.
Let me know if that fixes the DataStore error!