Created
July 30, 2021 16:42
-
-
Save RobertCodez/5e70a4fb65a4c7637feec0d1fea4d727 to your computer and use it in GitHub Desktop.
Twitter Codes | Uses Datastores
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local DataStoreService = game:GetService("DataStoreService") | |
local TwitterCodes = { Code1 = {"Cash", 2000} } | |
game.ReplicatedStorage.RedeemCode.OnServerInvoke = function(Player, Code) | |
local TwitterCodeStore = DataStoreService:GetDataStore("TwitterCodesStore2" .. Code) | |
local PlayerRedeemedCode = TwitterCodeStore:GetAsync(Player.UserId) | |
if TwitterCodes[Code] and not PlayerRedeemedCode then | |
local LeaderboardValueName = TwitterCodes[Code][1] | |
local AmountToGivePlayer = TwitterCodes[Code][2] | |
local LeaderboardValue = Player.leaderstats[LeaderboardValueName] | |
LeaderboardValue.Value = LeaderboardValue.Value + AmountToGivePlayer TwitterCodeStore:SetAsync(Player.UserId, true) | |
return true | |
else | |
return false | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment