Script:
local ds = game:GetService("DataStoreService"):GetDataStore("-WTssstttCodes01")
local Codem = game:GetService("ServerScriptService"):WaitForChild("CodeModule")
local CodeModule = require(Codem)
function checkForCode(Code)
local Codes = CodeModule.Codes
if Codes[tostring(Code)] then
return true
else
return false
end
end
game.Players.PlayerAdded:Connect(function(player)
local key = "codes-"..player.userId
local folder = Instance.new("Folder",player)
folder.Name = "Codes"
local save = ds:GetAsync(key)
if save then
for i = 1,#save do
local temp = Instance.new("BoolValue",folder)
temp.Name = save[i]
end
end
end)
game.ReplicatedStorage.EnterCode.OnServerEvent:Connect(function(player,Type,Amount,Item,code)
local key = "codes-"..player.userId
if checkForCode(code) == true then
if Type=="Stats" then
Item.Value = Item.Value + Amount
elseif Type=="Item" then
local ItemClone=Item:Clone()
Item.Parent=player:WaitForChild("Backpack")
end
local bool = Instance.new("BoolValue",player.Codes)
bool.Name = code
bool.Value = true
local activated = {}
for i,v in pairs(player.Codes:GetChildren()) do
if v:isA("BoolValue") then
table.insert(activated, v.Name)
end
end
ds:SetAsync(key,activated)
else
warn("INVALID CODE USED! MIGHT BE EXPLOITED!")
end
end)
Module Script:
local module = {
Codes = {
"Test",
"Test2",
},
}
return module
When it checks for a code that is valid and is in the module table it still prints that it is invalid and doesn't give player the reward.
