Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.