Module 6 · In Studio · challenge 2 of 2 in this lesson
DataService.claimDaily(player) returns granted and the new coin count
A test in Studio grades it and prints a pass code.
Open
Level 3, Professional
Challenge
Add a daily reward that is saved with the profile. Grade it on a branch from m14-ship (where ProfileStore runs DataService, covered in the next lesson) in a published place with API Services enabled. The test is challenges/datastores.luau, and the solution is challenges/solutions/datastores.md.
- Start from
- The game at milestone m14 (download)
- Grade it
- In Studio, press Play, then run
game.ServerScriptService.RunGameTests:Invoke("datastores", "datastores-daily")in the server command bar. Copy the pass code from Output.
Done means
- DataService.claimDaily(player) returns granted and the new coin count
- The first claim of a day adds 15 coins, updates leaderstats and saves via DataService.save(player); a second claim the same day adds nothing
- Self-check, the test does not grade it: if DataService.save(player) fails, claimDaily rolls back the coins and lastDailyDay
- DataService.readSaved(player.UserId) returns the saved lastDailyDay and coins, and challenges/datastores.luau prints TEST PASS for every check