Leaderstats Creator

Hello! Today I present to you my first actual plugin: Leaderstats Creator.

Download Links:

The actual plugin can be found here: Leaderstats Creator - Roblox
The source code (to check if it has viruses, please don’t reupload this) can be found here: LeaderstatsCreator Source - Roblox

How do I use this?

Once you install the plugin, it should show up in your plugins tab. Click it. It should show up a little black window (scale it up if you want). Click “Begin”. You might see this screen:


Don’t worry, just click the Make One! button. You are now greeted with this screen. 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:
leaderstats

That’s all I have for now, have a nice day!

31 Likes

Your plugin is really helpful and cool! But I suggest upgrading the UI a bit.

1 Like

How can I improve the UI? I’m not the best at making it.

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.

Sample script:

UpdateEvent.Name = "UpdateStat"
UpdateEvent.Parent = game.ServerStorage

function OnNewValue(stat,newValue)
script.Parent[stat].Value = newValue
end

UpdateEvent.Event:connect(OnNewValue)

--To fire this event:
--game.ServerStorage.UpdateState:Fire(stat,newValue)
--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.

I don’t understand why I would use BindableEvents or Functions for it, can you please elaborate?

A BindableEvent is a very simple way to allow external scripts to update values.

function updateStat(stat,newValue)
script.Parent[stat].Value = newValue
end

script.BindableEvent.Event:connect(updateStat)

No, I don’t use them. You can check the source code if you want to see what I do.

Using a bit of your feedback, I updated the plugin. Please update it and then restart studio.

1 Like

I’ve updated my feedback post accordingly.

Further feedback after reading through the generated script:

  • :thinking: 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.
1 Like

It now shows this if it is the first value (sorry about the gui handles, had them there when i took the screenshot) firstvalwarning

2 Likes

The last thing on this list doesn’t seem like a suggestion.

@c0mmandhat

I use a generated GUID because I could have duplicates in datastores. I can change that if you’d like.

How would I use UpdateAsync? It would take a while to implement, since I generate all of the code using Script.Source

1 Like

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)

I have a question does it make a data store when you click saveable?

1 Like

I was looking for something like this for a long time! You’re a hero lol :smiley:

1 Like

Yes, I guess. If data saving is true the data will save.

Really nice and simple I love the data store system.

1 Like

I find this to be really helpful with development!

2 Likes