Hello! I'm working on a game that has a code system. But I'm trying to add another code. (I have 1 code in my game now) But I'm struggling to find out how to figure it out! Checking the code if its wrong or right is invoked by a RemoteFunction located in Replicated Storage.
Button that Invokes the RemoteFunction (works fine):
local b = script.Parent
local codeInput = script.Parent.Parent.TextLabel.CodeIput
b.MouseButton1Click:Connect(function()
local result = game.ReplicatedStorage.CheckCode:InvokeServer(codeInput.Text)
if result == true then
codeInput.Text = "Success!"
else
codeInput.Text = "Code invalid or outdated!"
end
end)
Checking if the code is right or wrong (error):
game.ReplicatedStorage.CheckCode.OnServerInvoke = function(player, code)
if code == "Sub2Tenulty" then -- first code
local backpack = player:WaitForChild("Backpack")
local machete = game.ServerStorage["Tenulty's Machete"]:Clone()
machete.Parent = backpack
return true
else
return false
end
if code == "Sub2Kobe" then --second code
local backpack = player:WaitForChild("Backpack")
local machete = game.ServerStorage["Kobe's Machete"]:Clone()
machete.Parent = backpack
return true
else
return false
end
end

2 comments
Look at the first line you put OnServerInvoke = function when it should be OnServerInvoke:Connect(function(player, code)
onserverinvoke does not use connect because it isn't an event but a callback