I have a code event in replicated storage and I have 2 scripts 1 in server scrive service and another in the Gui
Server script service code:
local RemoteEvent = game.ReplicatedStorage.CodeEvent
RemoteEvent.OnServerEvent:Connect(function(Player,Reward,Code)
if Player:FindFirstChild(Code) == nil then
local Redeemed = Instance.new(“BoolValue”, Player)
Redeemed.Name = Code
Redeemed.Value = false
if Redeemed.Value == false then
Player.leaderstats.Money.Value += Reward
Redeemed.Value = true
end
end
end)
Ui Code
local codes = {“RELEASE!”,“REALISIM TIME”,“Dog”,“Cat”,“Subscribe”}
local RemoteEvent = game.ReplicatedStorage.CodeEvent
script.Parent.EnterButton.MouseButton1Click:Connect(function()
if script.Parent.InputBox.Text == codes[1] then
RemoteEvent:FireServer(50, codes[1])
else
if script.Parent.InputBox.Text == codes[2] then
RemoteEvent:FireServer(100, codes[2])
else
if script.Parent.InputBox.Text == codes[3] then
RemoteEvent:FireServer(200, codes[3])
else
if script.ParentBox.Text == codes[4] then
RemoteEvent:FireServer(160, codes[4])
else
if script.ParentBox.Text == codes[5] then
RemoteEvent:FireServer(400, codes[5])
end
end
end
end
end
end)
Going off your screenshot (which is much more helpful, thank you for that), I would use ifelse statements instead of using else statements then putting an if statement inside it.
Edit: You also labeled your code wrong in the screenshot reply. Your ServerScriptService code is labeled as the GUI code, and vice versa.
You need to have an end with a parentheses after it to close the MouseClickEvent. Also I’m pretty sure you should only have one regular end.
I suggest looking up ifelse statements on the DevHub because your code is still really messed up and I can’t make it for you right now because I don’t have access to my desktop. I will try to help you the best I can but I don’t know how to explain to you how to format the statements.
Instead of doing this, you can make something like this.
Codes = {
RELEASE = {
Money = 50
}
}
local RemoteEvent = game.ReplicatedStorage.CodeEvent
script.Parent.EnterButton.MouseButton1Click:Connect(function()
if table.find(Codes,script.Parent.InputBox.Text) then
local index = table.find(Codes,script.Parent.InputBox.Text)
RemoteEvent:FireServer(index.Money,index)
end
end)
try something along these lines, i’m not sure if table.find is the right function but if it doesnt work update me