I want to make a code that stops being available once first 100 players redeem it,
I was thinking using ordered data stores for it but I’m not too sure, need confirmation.
Any advice is greatly appreciated, thanks in advance
I want to make a code that stops being available once first 100 players redeem it,
I was thinking using ordered data stores for it but I’m not too sure, need confirmation.
Any advice is greatly appreciated, thanks in advance
that doesnt really make sense but if you are redemming something then you could add everyone thats redeemed the “script” or whatever to a data store and when you are running the redemption script check if the datastore is at 100 players if it is then dont redeem or run the rest of the script
You can make something like this:
local DSS = game:GetService("DataStoreService")
local DS = DSS:GetDataStore("CodesRedeem")
local enabled = true
function afterSomeRedeemTheCode()
local numOfplayersRedeemTheCode = DS:GetAsync("PlayersWhoRedeemTheCode") or 0
numOfplayersRedeemTheCode+=1
DS:SetAsync("PlayersWhoRedeemTheCode", numOfplayersRedeemTheCode)
if numOfplayersRedeemTheCode >= 100 then
enabled = false
end
end
You could have a global datastore with a single key, which increments by 1 every time someone redeems, and if someone tries to redeem and the value is over 100, you can call :RemoveAsync()
on the key
That’s what I was thinking, not too sure if it would work though, thanks!
Would this work globally? Or would I have to use this but replace with orderded data store?
ordinary global datastore theres no need for an ordered datastore
This had been achieved by the game Assassin, where there was a code for a knife that only the first 1000 players could get so I know it’s possible just not too sure on how to take it
well if you are giving people weapons you are going to need to use datastores to save their weapons in the first place so you should learn how to use datastores and then you’ll understand why everyone is saying use a datastore because the datastore will be the same across all servers of the game so the first 100 players can be measured properly
Oh I can, I just use loleris ProfileService Module which sets up everything and I have tables that can store & save weapons
I wasn’t thinking straight but thought ordered/global data store were the same but I thank you for the info, I just needed confirmation that using global data store would help me achieve my goal
Yes, but I would suggest using UpdateAsync instead