Simple Twitter Code System for Beginners

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

I think I might use this as a module system was used for guest quest back in the day by build. Plus with rate limits and whatnot it’s better imo

I’m really sorry to revive this but:
Your System is solid. But if anyone finds that asset he/she could easily redeem all the codes. I would rather use a combination of MessagingService and DataStores.

How would you use MessagingService for codes?

I just use pastebin with an unlisted paste, it’s a lot harder to find and it still follows the basic principles of this tutorial. Also it’s a lot easier to maintain and implement than datastores in my opinion.

i store my codes aswell in a pastebin.
My code base goes as follow:

"Code:{“Active”:true,“Rewards”:[{“Type”:“Cash”,“Amount”:20}]}

then do a loop through the Code.Rewards list and check the Type then give them the Amount

1 Like

Nice tutorial! Working on a project that I will really need this system for. Convenient. :slight_smile:

1 Like

I would use a MessagingService channel for adding new coded to the System.

got an example pastbin er, doc, I can use to see how it needs to be strucutred?