No, it’s okay. If someone did this for me starting off, I would’ve learned programming 10x faster, so I know how she’s feeling right now.
I just want to see any tutorials how to do it, because I’ll never do it without it
Do you already have the GUI elements or do you need to learn that as well?
That was a little harsh of you to be honest…
I didn’t mean it to be rude, sorry. I was gonna link some videos.
I don’t have it, but I can one because my game consists of them.
My apologies if that came of as rude.
Your use case is kinda hard to find a video for, so I can give you a more detailed step by step if you would like.
Also do you have any scripting experience?
It’s okay if I can’t find it, I can make a simple code system without any max usages.
It’s too easy for me, when I started to make games 2-3 years ago
Okay, so you need to make 2 GUI system, thats for certain. 1, where you can add the codes and another one where you can redeem it. There’s actually a bunch of videos on youtube if you type something like “roblox code redeem script”
The issue would be how you connect both those systems. I don’t think theres many videos on that… If so I can’t find it.
Again, this is what I would do personally. First create a gui for your adding code GUI and a redeem GUI. Create 2 local scripts, add one to each GUI. Create 1 server script in the serverscriptservice and 2 module scripts in the server storage and rename them something like AdminList and CodesList
For your adding code GUI:
- In the local script, add a listener for when you enter code and money via like textbox or something. Make sure to store the code and money in some var. Here’s a link to a tutorial for textbox stuff, it doesn’t store the text, but make sure you do: Text Input | Documentation - Roblox Creator Hub
- When that event occurs, fire a remote to the server script with the code and money.
- In the server script, require the admin and the codes module script, then listen for the remote event.
- For validation, check if the player from the remote is part of the admin list, if they are then add the code and money in the CodesList like this: CodesList[code] = money
This should finish that GUI system now, onto the next.
For redeem GUI:
- In the local script, I assume you want only like a textbox for players to enter code, so have the textbox listener again. This time you don’t need to store the code, so when the event fires, so when player enters the code and presses enter, send a remote with the code information.
- Now in the server script, listen for this remote and do validation like is the code part of the CodesList, if so then find it and give the money to the player.
This is more indepth compared to my previous reply, so hope it helps. If you want to add your max usage, you can do so as well with this code, you just have to add some more things.
Here is a tutorial that I was going to send to you, if you only wanted to have a redeem system. In this system I think you add codes via the script itself not from a GUI. https://www.youtube.com/watch?v=vW5sQrVOQsA
I have a code system like this, but it’s looks more comfortable, when you can add new code just by adding it on list and typing value of money. Thx!
NP, i might have some time later to make the GUI system for you like a tutorial, but I’m working on something else rn. I am a bit stuck with my own problems, so If I can’t fix my issue soon, I will try to make this tutorial for ya to make my mind a bit more refreshed.
Thanks, but I know and can do this without any tutorials
IN THIS STEPS/SYSTEM, it only works of in game/server you are in.
To add the code to all servers using these steps, scrap the CodesList module and store the codes and stuff in a the data store service!
Ik, all things in my game has been stored as Data DataStore
I was replying to anybody else who wanted to use that system that I showed since you marked it as solution.
mk, I would start with DataStoreService to store the codes somewhere, along with its data, such as say, the reward money, and if you want, the amount of times it can be used.
First, lets start by setting up our DataStore, and accessing it with a name - Cloud.
local DataStoreService = game:GetService('DataStoreService')
local CloudDataStore = DataStoreService:GetDataStore('Cloud') --//Cloud being our DataStore name
So, when you save data, you can grab it at any time. Now since we don’t have any data saved, we’ll use “Codes_DataStore” as an example. Since DataStoreService can sometimes fail we have to wrap it in a Pcall to ensure no errors break our code.
local DataStoreService = game:GetService('DataStoreService')
local CloudDataStore = DataStoreService:GetDataStore('Cloud') --//Cloud being our DataStore name
local DataStore_Scope = 'Codes'
local Seconds_In_a_Day = 86400
local Days_Code_Active = 7
local Codes_DataStore = {} --//Imagine this is a already saved DataStore with a Scope of "Codes"
function SetAsync_Codes_DataStore ()
end
function GetAsync_Codes_DataStore ()
while true do
local Success, Response = pcall(function()
return CloudDataStore:GetAsync(DataStore_Scope)
end)
if Success then
if Response then
Codes_DataStore = Response --//Personally, I save it to a variable for quick access.
else
SetAsync_Codes_DataStore()
end
break --//Break from the loop
else
wait(7) --//Optimal DataStore cooldown time
end
end
end
Now we can add our codes! Although, you don’t want to override any existing code data, so what do we do now? Since we saved our Codes DataStore locally to a variable called “Codes_DataStore,” we can check if the code already exists, or needs to be added! Assuming the code is fairly new we can add it to our Codes_DataStore dictionary! and of course we’ll need to save it to DataStores right after.
local DataStoreService = game:GetService('DataStoreService')
local CloudDataStore = DataStoreService:GetDataStore('Cloud') --//Cloud being our DataStore name
-----------------------------
local DataStore_Scope = 'Codes'
local Seconds_In_a_Day = 86400
local Days_Code_Active = 7
local Codes_DataStore = {} --//Imagine this is a already saved DataStore with a Scope of "Codes"
function SetAsync_Codes_DataStore () --//Basically, the same thing as GetAsync, but we're "Setting" it
while true do
local Success, _ = pcall(function()
CloudDataStore:SetAsync(DataStore_Scope, Codes_DataStore) --//(Argument #2) being our Codes_DataStore Dictionary.
end)
if Success then
break
else
wait(7)
end
end
end
function GetAsync_Codes_DataStore ()
while true do
local Success, Response = pcall(function()
return CloudDataStore:GetAsync(DataStore_Scope)
end)
if Success then
if Response then
Codes_DataStore = Response --//Personally, I save it to a variable for quick access.
else
SetAsync_Codes_DataStore()
end
break --//Break from the loop
else
wait(7) --//Optimal DataStore cooldown time
end
end
end
--------------------------
local CodeA_Key = 'YourCodeNameHere'
if not Codes_DataStore[CodeA_Key] then --//If the Key "CodeA_Key," does not exist in our dictionary, then proceed to add it
Codes_DataStore[CodeA_Key] = {
['Cash'] = 0,
['Timer'] = tick() + (Seconds_In_a_Day * Days_Code_Active), --//Basically, saving our current epoc time(tick) plus 7 times the seconds in a day (7 days).
['Redeemed'] = {},
['MaxRedeems'] = 0, --//Optional for maximum redeems
}
SetAsync_Codes_DataStore() --//We want to save the codes to DataStore for the future
end
Now, recall that data across the game. For instance, if a player decides to use the code ‘YourCodeNameHere’ (aka CodeA), you can check if the code is still active. Then, proceed to see if the player has already redeemed it. Finally, add any cash from there!
local DataStoreService = game:GetService('DataStoreService')
local CloudDataStore = DataStoreService:GetDataStore('Cloud') --//Cloud being our DataStore name
-----------------------------
local DataStore_Scope = 'Codes'
local Seconds_In_a_Day = 86400
local Days_Code_Active = 7
local Codes_DataStore = {} --//Imagine this is an already saved DataStore with a Scope of "Codes"
function SetAsync_Codes_DataStore () --//Basically, the same thing as GetAsync, but we're "Setting" it
while true do
local Success, _ = pcall(function()
CloudDataStore:SetAsync(DataStore_Scope, Codes_DataStore) --//(Argument #2) being our Codes_DataStore Dictionary.
end)
if Success then
break
else
wait(7)
end
end
end
function GetAsync_Codes_DataStore ()
while true do
local Success, Response = pcall(function()
return CloudDataStore:GetAsync(DataStore_Scope)
end)
if Success then
if Response then
Codes_DataStore = Response --//Personally, I save it to a variable for quick access.
else
SetAsync_Codes_DataStore()
end
break --//Break from the loop
else
wait(7) --//Optimal DataStore cooldown time
end
end
end
--------------------------
local CodeA_Key = 'YourCodeNameHere'
if not Codes_DataStore[CodeA_Key] then --//If the Key "CodeA_Key," does not exist in our dictionary, then proceed to add it
Codes_DataStore[CodeA_Key] = {
['Cash'] = 0,
['Timer'] = tick() + (Seconds_In_a_Day * Days_Code_Active), --//Basically, saving our with the current epoc time plus, 7 days in seconds.
['Redeemed'] = {},
['MaxRedeems'] = 0, --//Optional for maximum redeems
}
SetAsync_Codes_DataStore() --//We want to save the codes to DataStore for the future
end
-------------------------
RemoteEvent.OnServerEvent:Connect(function(Player, CodeKey)
if Codes_DataStore[CodeKey] then --//Does the code exist in our Codes_DataStore?
if (Codes_DataStore[CodeA_Key]['Timer'] > tick()) then --//Is Code Expired?
if not table.find(Codes_DataStore[CodeA_Key]['Redeemed'], Player.UserId) then --//Did player already redeem code?
--//OPTIONAL
if (#Codes_DataStore[CodeA_Key]['Redeemed'] > Codes_DataStore[CodeA_Key]['MaxRedeems']) then --//Total Redeemed (is greater than) Max Redeem
return
end
--
--//Give player cash!
table.insert(Codes_DataStore[CodeA_Key]['Redeemed'], Player.UserId) --//Add player to Redeemed list
end
end
end
end)
This was a lot more than I thought and had to restart a couple of times. Sorry it took so long, but please feel free to ask any questions. I would love to help out as much as possible!
Omg, that’s it! Thanks for your solution!
Of course, thank you! And please feel free to ask any questions.