Redemption Codes System

But what to do after table.insert(Codes_DataStore[CodeA_Key][‘Redeemed’], Player.UserId)? Just type Player.leaderstats.Money.Value += Codes_DataStore[CodeA_Key][‘Cash’]?

Yes, that’s correct!


1 Like

That’s actually that what I searched for!

1 Like

And I just need to make a gui with button, textbox and localscript with text:
local Button = script.Parent

function onRedeemed()
if (way to textbox).Text ~= “” then
(Way to remote event):FireServer((way to textbox).Text)
end
end

Button.MouseButton1Click:Connect(onRedeemed)
?

Yes, you only need to send the codes key (name of the code)

1 Like

Ik, I maded transfer money system in my game like it, all you need to do it’s just to type Amount and PlayerName to send it, and click on Confirm

1 Like

Thanks! That’s last my question.

1 Like

Hi again, I just maked the system, and maked a line that prints how many codes is already activated, but it prints count that I typed on script. What to do?

And also after rejoin a can get money again

Count?


I typed 12 to test it on another accounts

Oh, did you save the datastore after someone redeemed it?

Although, there are for efficient ways of doing it, I think this’ll be okay for now.

Hmm, second, I’ll test for it
.
.
.
.
.

Like this one:

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
			Player.leaderstats.Money.Value += Codes_DataStore[CodeA_Key]['Cash']
			print(Codes_DataStore[CodeA_Key]['MaxRedeems'])
			CloudDataStore:SetAsync(Codes_DataStore[CodeA_Key]['MaxRedeems'])
		end
	end
end

end)

?

Buggy post
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.

.

Nice, argument 2 mission or nil

Bruh, Idk how to save it
.
.
.
.
.
.
.
.

It doesn’t even save it and change maxredeems value

You’re not saving anything here, you need to set the value in SetAsync(Key, Value) where the value being Cloud_DataStore variable and the Key being Codes (AKA DataStore_Scope)

CloudDataStore:SetAsync(Codes_DataStore[CodeA_Key]['MaxRedeems'])

This is the first time I have encountered this, the only thing I know it’s save leaderstats.