Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

Code Gui Not Working Correctly, Doesnt give the item and doesnt change the textbox's test??

Asked by
LuaDLL 253 Moderation Voter
6 years ago

Creating a code gui to give you items like miners haven and it isn't working right.

local Codes = {
    ["Test"] = "Basic Iron Mine",
}
local UsedCodes = {}

script.Parent.MouseButton1Click:Connect(function()
    local Code = script.Parent.Parent.Code
    for i,v in pairs(Codes) do
        for g,h in pairs(UsedCodes) do
            if Code.Text == i and not Code.Text == g then
                script.Parent.Parent.Parent.AddItem:InvokeServer(v,1)
                Code.Text = "Successfully Redeemed!"
                table.insert(UsedCodes,i)
            elseif Code.Text ~= i or Code.Text == g then
                Code.Text = "Invalid Code Or Already Redeemed!"
            end
        end
    end
end)

Doesn't print any errors

1 answer

Log in to vote
0
Answered by 6 years ago
local Codes = {
    ["Test"] = "Basic Iron Mine",
}

script.Parent.MouseButton1Click:Connect(function()
    local Code = script.Parent.Parent.Code.Text
    if Codes[Code] then
        script.Parent.Parent.Parent.AddItem:InvokeServer(Codes[Code],1)
        Code.Text = "Successfully Redeemed!"
        Codes[Code] = nil
    else
        Code.Text = "Invalid Code Or Already Redeemed!"
    end
end)
Ad

Answer this question