Hey developers,
Today i decide to release a very simple redeem code system !
What is redeem code ?
This is a user interface, where you can type a certain code and receive a reward !
This pack include:
- The complete Ui design, already fully programmed
- All required sounds
- All leaderstats currency + Save
- The code system & programmation
File: Redeem Code.rbxl (41,5 Ko)
How to use it ?
Open the “Codes” Script in the ServerScriptService and follow the instructions.
Everything is explained, easy and fast to edit.
You can change the Ui placement / design how you want, just take care to don’t break the script unless you are able to edit it.
It require to have the place published on a game with api enabled to access datastore save system.
Screenshots
My other ressources
Scripts
[Update] Currency Local Script
local Player = game.Players.LocalPlayer
local leaderstats = Player:WaitForChild("leaderstats" ,10)
if leaderstats ~= nil then
local Coins = leaderstats:WaitForChild("Coins" ,5)
local Gems = leaderstats:WaitForChild("Gems" ,5)
if Coins ~= nil then
script.Parent.Coins.Info.Text = Coins.Value
Coins.Changed:Connect(function()
script.Parent.Coins.Info.Text = Coins.Value
end)
end
if Gems ~= nil then
script.Parent.Gems.Info.Text = Gems.Value
Gems.Changed:Connect(function()
script.Parent.Gems.Info.Text = Gems.Value
end)
end
end
[MainScript] Code Local Script
local Player = game.Players.LocalPlayer
local Codes = Player:FindFirstChild("Codes")
local Button = script.Parent.Button
local Frame = script.Parent.Frame
local Close = Frame.Close
local Redeem = Frame.Redeem
local TextBox = Frame.TextBox
local CodesFolder = game.ReplicatedStorage.Codes
local ButtonSound = game.SoundService.Button
local ErrorSound = game.SoundService.Error
local RedeemSound = game.SoundService.Redeem
--
Button.MouseButton1Click:Connect(function()
if Frame.Visible == false then
Frame.Visible = true
ButtonSound:Play()
elseif Frame.Visible == true then
Frame.Visible = false
ButtonSound:Play()
end
end)
Close.MouseButton1Click:Connect(function()
Frame.Visible = false
ButtonSound:Play()
end)
--
local function CodeRedeemed()
if Codes ~= nil and not Codes:FindFirstChild(TextBox.Text)then
ButtonSound:Play()
ErrorSound:Play()
TextBox.Text = ""
TextBox.PlaceholderText = "Invalid Code"
TextBox.PlaceholderColor3 = Color3.new(1, 0.313725, 0.313725)
wait(0.5)
TextBox.PlaceholderText = "Type Here"
TextBox.PlaceholderColor3 = Color3.new(0.698039, 0.698039, 0.698039)
elseif Codes ~= nil and Codes:FindFirstChild(TextBox.Text) and Codes:FindFirstChild(TextBox.Text).Value == true then
ButtonSound:Play()
ErrorSound:Play()
TextBox.Text = ""
TextBox.PlaceholderText = "Code Already Redeemed"
TextBox.PlaceholderColor3 = Color3.new(1, 0.313725, 0.313725)
wait(0.5)
TextBox.PlaceholderText = "Type Here"
TextBox.PlaceholderColor3 = Color3.new(0.698039, 0.698039, 0.698039)
elseif Codes ~= nil and Codes:FindFirstChild(TextBox.Text) and Codes:FindFirstChild(TextBox.Text).Value == false then
local Event = CodesFolder:FindFirstChild(TextBox.Text)
if Event ~= nil then
Event:FireServer(Player)
ButtonSound:Play()
RedeemSound:Play()
TextBox.Text = ""
TextBox.PlaceholderText = "Code Redeemed"
TextBox.PlaceholderColor3 = Color3.new(0.333333, 1, 0.498039)
wait(0.5)
TextBox.PlaceholderText = "Type Here"
TextBox.PlaceholderColor3 = Color3.new(0.698039, 0.698039, 0.698039)
end
end
end
Redeem.MouseButton1Click:Connect(function()
CodeRedeemed()
end)
TextBox.FocusLost:Connect(function(enterPressed)
if enterPressed then
CodeRedeemed()
end
end)
[Leaderstats] Currency Server Script - Create and Save
game.Players.PlayerAdded:Connect(function(Player)
local DataStore = game:GetService("DataStoreService")
local ds = DataStore:GetDataStore("LeaderSave")
if not Player:FindFirstChild("leaderstats") then
local Folder = Instance.new("Folder" ,Player)
Folder.Name = "leaderstats"
end
local Folder = Player:WaitForChild("leaderstats" ,5)
local Coins = Instance.new("IntValue",Folder)
local Gems = Instance.new("IntValue",Folder)
Coins.Name = "Coins"
Gems.Name = "Gems"
---------------------------------------------------------
local GetData = ds:GetAsync(Player.UserId)
if GetData ~= nil then
Coins.Value = GetData[1]
Gems.Value = GetData[2]
else
Coins.Value = 0
Gems.Value = 0
end
end)
game.Players.PlayerRemoving:Connect(function(Player)
local DataStore = game:GetService("DataStoreService")
local ds = DataStore:GetDataStore("LeaderSave")
local SaveData = {}
for _,Child in pairs(Player.leaderstats:GetChildren())do
table.insert(SaveData,Child.Value)
end
ds:SetAsync(Player.UserId, SaveData)
end)
[Codes] Codes Server Script - Create, Save and rewards
game.Players.PlayerAdded:Connect(function(Player)
local DataStore = game:GetService("DataStoreService")
local ds = DataStore:GetDataStore("CodesSave")
if not Player:FindFirstChild("Codes") then
local Folder = Instance.new("Folder" ,Player)
Folder.Name = "Codes"
end
local Folder = Player:WaitForChild("Codes" ,5)
local CodeOne = Instance.new("BoolValue",Folder) --Rename by the wanted code name
local CodeTwo = Instance.new("BoolValue",Folder) --Rename by the wanted code name
local CodeThree = Instance.new("BoolValue",Folder) --Rename by the wanted code name
--local CodeFour = Instance.new("BoolValue",Folder) --Duplicate and rename to add another code
CodeOne.Name = "CodeOne" --Rename by the created code name
CodeTwo.Name = "CodeTwo" --Rename by the created code name
CodeThree.Name = "CodeThree" --Rename by the created code name
--CodeFour.Name = "CodeFour" --Duplicate and rename by the new added code
---------------------------------------------------------
local GetData = ds:GetAsync(Player.UserId)
if GetData ~= nil then
CodeOne.Value = GetData[1] --Rename by the created code name
CodeTwo.Value = GetData[2] --Rename by the created code name
CodeThree.Value = GetData[3] --Rename by the created code name
--CodeFour.Value = GetData[4] --Duplicate and rename by the new added code - Don't forget to change the number !
else
CodeOne.Value = false --Rename by the created code name - let the value on "false"
CodeTwo.Value = false --Rename by the created code name - let the value on "false"
CodeThree.Value = false --Rename by the created code name - let the value on "false"
--CodeFour.Value = false --Duplicate and rename by the new added code - let the value on "false"
end
end)
game.Players.PlayerRemoving:Connect(function(Player)
local DataStore = game:GetService("DataStoreService")
local ds = DataStore:GetDataStore("CodesSave")
local SaveData = {}
for _,Child in pairs(Player.Codes:GetChildren())do
table.insert(SaveData,Child.Value)
end
ds:SetAsync(Player.UserId, SaveData)
end)
---------------------------------------------------------
for _, Events in pairs(game.ReplicatedStorage.Codes:GetChildren())do
if Events:IsA("RemoteEvent")then
Events.OnServerEvent:Connect(function(Player)
local Codes = Player:FindFirstChild("Codes")
local leaderstats = Player:FindFirstChild("leaderstats")
if Codes ~= nil and leaderstats ~= nil then
local Code = Codes:FindFirstChild(Events.Name)
local Coins = leaderstats:FindFirstChild("Coins")
local Gems = leaderstats:FindFirstChild("Gems")
if Code ~= nil and Coins ~= nil and Gems ~= nil and Code.Value == false then
Code.Value = true
if Code.Name == "CodeOne" then --Rename by the created code name
Coins.Value = Coins.Value + 100 --Coins reward related to this code name
Gems.Value = Gems.Value + 50 --Gems reward related to this code name
elseif Code.Name == "CodeTwo" then --Rename by the created code name
Coins.Value = Coins.Value + 250 --Coins reward related to this code name
Gems.Value = Gems.Value + 125 --Gems reward related to this code name
elseif Code.Name == "CodeThree" then --Rename by the created code name
Coins.Value = Coins.Value + 500 --Coins reward related to this code name
Gems.Value = Gems.Value + 250 --Gems reward related to this code name
-- elseif Code.Name == "CodeFour" then --Rename by the created code name
-- Coins.Value = Coins.Value + 750 --Coins reward related to this code name
-- Gems.Value = Gems.Value + 375 --Gems reward related to this code name
end
end
end
end)
end
end