Simple Twitter Code System for Beginners

So apparently the filter changes randomly and now the code “500K” will not allow you to update the description, just an FYI for anyone wanting to use that code.

2 Likes

Nice tutorial overall but I suggest you modify some things as I do not think they are right. First of all, why are you using asset descriptions to save your codes? That is not a good idea as there is a really small limit to the amount of characters that an asset can handle on its description and not only that but ROBLOX filters its asset description which means that your description might end up being tags, secondly if the players find your asset then instead of going to your twitter and finding codes they will just go to the assets, see the codes and enter them. That is something you do not want. Lastly, :GetProductInfo(assetId) caches, that means that you will have the same result as storing your codes in a table because the new codes will update when the server reboots only. And rebooting all of your servers just for a twitter code does not seem like a good idea. From what I can see you were using :GetProductInfo(assetId) on an asset so you could just update the asset and the changes would be made in real time to the server, but they won’t as :GetProductInfo(assetId) caches. I think using HttpServices or DataStores probably the best way of doing this. Also I suggest you store codes along with functions as @DevLuka suggested. It is a better way rather than storing the codes your way. What if you would want to give an item as a reward to the player? Not only that but it is also more practical and easier. Also if you really want to store your codes in assets, which imo is not a good idea you should use a proxy to send a request to your asset and get its description, it shouldn’t be that hard to program a proxy, from what I am aware of there is already an open source proxy made for ROBLOX. It is called rproxy iirc. The best way to make a twitter code system probably is to create a website so you can put your codes there and send a HttpRequest to your website and get the codes, alternatively put some security to the website so you would need to send a http request containing a passcode, if the passcode would be correct than it would return the JSON list of the codes. Real time changes and more efficient.

You do realize that the whole purpose of this post is to make a barebones twitter code system right? And what you are saying about caching isn’t correct either. Maybe you should look up the api and actually read the post before you make an entire rant? :upside_down_face:

2 Likes

It isn’t a rant, I am just saying what things could possibly be fixed or improved. And :GetProductInfo() does cache. What do you mean? Also I understand that this is supposed to be a basic twitter code system, I was just giving my opinion on what could be changed for good.

Wiki doesn’t state that it caches and in game I can easily update the assets description and have the codes work perfectly fine in live servers without shutting down. Also stating what can be fixed or improved doesn’t help at all because thats not the purpose of this resource…

2 Likes

I understand that that is not the purpose of the resource, and the fact that it says nothing in the wiki doesn’t mean it doesn’t cache, :GetRoleInGroup() caches too but there is nothing in the wiki. You can go ahead and test if :GetProductInfo() caches if you do not believe me, I just tested it today and it did cache.

It doesn’t cache, trust me. It will return the new description after a min or so after updating. If anything it caches for that small amount of time.

2 Likes

I thought :GetProductId() cached because I did not know it requierd like 1 minute for the changes to be applied, when I tested it, I only did so for like 10-20 seconds. Also ROBLOX should definitely say if a function caches or no to prevent such incidents. By the way:
image

This is a low quality tutorial. You’d never use a product’s description in a real game for reasons someone else already specified. Even if you didn’t want to make the tutorial more complicated with HttpService, storing codes in a table and / or using DataStoreService would be the obvious alternative., Additionally, there’s not a single check to see if the player has already redeemed a code.

Not to mention that code like this is just bad, and that it wouldn’t take much to improve it:

tats[codes[code][1]].Value = stats[codes[code][1]].Value + codes[code][2]

The code can error since it makes a remote call, causing the thread to terminate. The author was informed of this but ignored it.

This is sloppy. If an author isn’t willing to put in minimal effort when writing a tutorial, it’s best for them to refrain from doing so at all. There is no utility in an improperly implemented “barebones” system.

As one last point, Instance:FindFirstChild() should be used to locate the stat value in case someone wants to use a “Name” or “Value” stat during testing, even in a barebones system.

6 Likes

This is already implemented and it is assumed you are already using your own data storage method.

This easy to use code can allow you to update/add codes without even opening studio or having a database and doesn’t require third party alternatives, hence beginner.

Why would you need to hide your codes? Once you tweet them they are already released to the public anyways and if somebody does happen to find the specific asset, what good is it to them anyways? Remember, beginner system.

How would that affect this code in any way? If the web call fails since the function is called through a RemoteEvent, the user can just try again. Nothing would break in this situation.

stats[codes[code][1]].Value = stats[codes[code][1]].Value + codes[code][2]

I use this system in games with millions of plays and it has yet to fail once. Please rant somewhere else.

2 Likes

You check if the code exists. You do not check if the player already redeemed it. You do not store a table of codes the player has already redeemed anywhere, or assume one exists.

There’s no guarantee it will be called that way in your code. Regardless, errors would clog output unnecessarily and may annoy error monitoring systems, which you’d want to avoid. This should be accounted for by calling these unsafe functions in protected mode.

I should’ve specified that what I take issue with is that descriptions have limited space and can be filtered.

Your response to mine and other people’s feedback is entirely unconstructive. All criticism is a “rant”.

3 Likes

“This is sloppy. If an author isn’t willing to put in minimal effort when writing a tutorial, it’s best for them to refrain from doing so at all. There is no utility in an improperly implemented “barebones” system.”

Reads like a rant to me. Easy to leave constructive criticism without giving New Members like yourself a bad name. The code works exactly how it is documented, users can easily follow recommendations given from the threads responses. No need to tell me how to code.

5 Likes

Question; how is using an asset description better than just sticking the table in a ModuleScript and requiring by asset ID? Much simpler and more robust, without having to deal with JSON:

return {
    GEMS = {
        Gems = 25
    }
}

edit: this won’t update in old servers, whoops

not even if you require it again?

If I remember correctly, require() caches the result even for asset IDs?

Not sure if this is off topic since it sort of pertains to the topic of storing codes but could you use GetAsync to request text from a discord channel to retrieve codes or even a google doc ?

I do not think it is possible to get a certain message from a discord channel, but you could use a google doc. In my opinion that would be a better idea as there is no character limit and it is 100% sure that after you make your changes to the doc file, your data won’t be tags.

1 Like

You would need to make sure you have your google api key for that specific document. If you want to use Google Docs or Google Spreadsheet, also make sure you are not calling the API too many times since they have limits. Spreadsheet will also need an API access key. If you don’t want to use an access key you will need to make the doc/spreadsheet public, which should be fine since the link will be server side on your game and not visible to clients.

Or you could just program your own site where you can send a specific request to it with a pass code, if the pass code is correct then the server will give you the codes. It shouldn’t be too hard either. I am indeed thinking of making one and open-sourcing it.

It does indeed, but I came up with a solution :slight_smile:. I made a function which requires a module by its id without caching! It basically uses InsertService to do this:

local function NoCacheRequire(id)
	local succ, err = pcall(function()
	local LatestVersionOfAsset = game:GetService("InsertService"):GetLatestAssetVersionAsync(id)
	asset = game:GetService("InsertService"):LoadAssetVersion(LatestVersionOfAsset)
	end)
	if not succ then return "error" end
	local module = asset:FindFirstChildOfClass("ModuleScript")
	if not succ or module == nil then return "error" end
	asset:Destroy()
	return require(module)
end

I hope you find it useful!

P.S: For people who do not want to use HttpService, this would be probably the best method for storing the twitter code data. You could also use this for different things too, not only twitter code data.

3 Likes