Just click the Add button. In the value type, choose which one you want (I don’t recommend bool, since in the playerlist false shows as 0 and true shows as 1). You can type the value name, then type in the default value. Set data saves to “Yes” or “No”. If you press yes, you need to make sure Studio Access to API Service is on! And then click Create. Now let’s say you didn’t want that stat. Click the trash button next to the stat.
Lastly, you can compile the leaderstats into a script by clicking the “Create Script” button. It has a warning telling you that you will not be able to edit the leaderstats anymore. If you want to add something else, you should click Back. Otherwise, click Continue. Once you click Continue, it should load for a second, then set your selection to a script in ServerScriptService called “leaderstats”. Test the game. It should work. if it doesn’t, tell me
Mine turned out like this:
Some feedback from the screenshots you’ve embedded in the post:
It’s not obvious from the first screenshot that the “Make One!” text is a button. I’d add an outline around the text, something like 1px white.Solved
“+add” is similarly ambiguous. What are you adding? A script? A number? A variable? An image? I suggest making this button longer and changing it to say “+ Add Stat”.Solved, somewhat; the button is somewhat small, but still readable
“Create Script” is not as ambiguous, but does not give any indication that this finalizes changes. I’d consider adding a red border around the button, but keeping the text white.Solved
Your ordering of the items in the creator GUI seems confusing. I’d change it to have the variable name first, followed by the default value, and then a checkbox for whether the value is datastored.
I like the trash button! Makes it immediately obvious what the button does. More people need to consider using icons instead of text.Not an issue
You should also emphasize that the first stat added to the leaderboard is how the leaderboard will be sorted. So if your first stat is “deaths”, then the player with most deaths will be at the top of the scoreboard.Solved
Please consider hooking up stats to a BindableEvent so that other serverside scripts could easily update them.
UpdateEvent.Name = "UpdateStat"
UpdateEvent.Parent = game.ServerStorage
script.Parent[stat].Value = newValue
--To fire this event:
--This line is for scripters, for example, if the person using the plugin is
--also working together with a scripter who wants to be able to update the
--leaderstats using their own scripts.
Further feedback after reading through the generated script:
why are you using a generated UUID? It seems like the only way I could find the leaderboard again, if i accidentally delete the script, is to use a datastore browser. This is not a complaint, just something I’m curious about.
WARNING: YOU ARE USING SetAsync INSTEAD OF UpdateAsync !!! SetAsync runs two datastore operations. The first operation clears whatever value is set, and the second operation sets the new value. This is very risky, as if the first operation runs, but not the second, then the datastore value is completely lost. It’s recommended to just flat-out replace SetAsync with UpdateAsync, which keeps the old value if the new value is not saved.
The last thing on this list doesn’t seem like a suggestion.
Fixed, with example script added. (Note: You should be able to just copy and paste the entire thing.)
How would I use UpdateAsync?
The same way you use SetAsync right now, with one minor change. UpdateAsync only works when the value already exists, so you should first check if the DataStore value exists. (you could try wrapping a GetAsync in a pcall, so that if it fails, you know the value doesn’t exist and should use SetAsync to create it first)