A 1 time run script

Hey there. I’m currently trying to make a twitter code system I was wondering how hard it is to make it so that they can only type the code once without making a datastore. I tried doing it with a datastore but all my UI’s need to be local script so I can’t really use a value if you could help me out or point me to a Wiki that would be awesome! Kind Regards ZoomCode

1 Like

Perhaps you could check this out: Twitter Code Plugin [Beta], made by uhTeddy.

1 Like

This is impossible to do on only the client. Currently there are no methods of storing data on the client for long periods of time and this is (in general) insecure since any exploiter can abuse this system.

You’ll want to use Remotes for this. These allow you to send data to and from the server. When the player inputs a code you can simply send it to the server using a RemoteFunction and the server can respond by returning a value in the callback. It can respond with almost anything. An instance, a table, a number, a string, and everything else. You can for example, return a table with a Success property and a Message property.

You can then use DataStores to store these codes and the server can process them and send them to the client if needed.

I don’t recommend using InvokeClient since this allows an exploiter to make the RemoteFunction yield (pause) forever on the server unless you know what you’re doing with these. When using this in separate threads (other scripts, functions called with spawn, event callbacks, etc) you should be fine though.

3 Likes

As @Hexcede said, this is a terrible way to make a twitter code system. You would need to use remote functions to send the value to the server, check if it’s a code and if it hasen’t been used yet using datastores, and then said the success/fail message back to the UI to tell the client.

1 Like

In layman’s terms, think of the client as RAM, once your computer shuts off, the RAM is volatile and will lose all of the data that is stored on it. In the same way, once the player leaves the game, all of the client data is lost, if this wasn’t the case there would never be a loading screen.

But how do games store my data?

  • Most games take advantage of DataStore, which is a service Roblox has that is required to be on the server and it is used to store your data, they then take advantage of RemoteEvents and RemoteFunctions to send a message to the server which in turn returns the specific player’s data.

Back to the issue at hand, the problem with having an all client twitter code system is that as said by @Hexcede, is that there is no way for us to store data on the client, and we would not want to do that anyway as anything on the client is easily changed by anyone who has the know-how to do so.

There have been multiple open-source systems that have been written to help people create systems like this, one of them is the Twitter Code Plugin referred to by @DesiredFlamingFire, and the other is a system that takes advantage of JSON so that you can add codes without having to shut down your game, it is up to you which one you want to use, or you could create your own.

Link to the topic here:

2 Likes

Hello there,
It is currently impossible to do it with just local scripts. But you can fire a RemoteEvent when the code is claimed and save the code to a datastore.

To check if the code was already redeemed you can look at the DataStore.

1 Like

Thank you all for the help! I’ll try it out! Thanks again.

1 Like