so it only works with "code1" but not "code2", and idk what's wrong
game.ReplicatedStorage.cd.OnServerEvent:Connect(function(player,code)
local ss = game:GetService("ServerStorage")
local reward = ss:FindFirstChild("PlayerMoney")
local r = reward:FindFirstChild(player.Name)
local key = "codes-"..player.userId
if code == "code1" then
if player.Codes:FindFirstChild(code) == nil then
local bool = Instance.new("BoolValue")
bool.Parent = player:FindFirstChild("Codes")
bool.Name = code
r.Value = r.Value + 500
elseif code == "code2" then
if player.Codes:FindFirstChild(code) == nil then
local bool = Instance.new("BoolValue")
bool.Parent = player:FindFirstChild("Codes")
bool.Name = code
r.Value = r.Value + 500
end
end
end
end)

2 comments
I don't understand what your trying to make here of this script?
Can you add what the local script says?