Error: attempt to index nil with 'Connect'?

Havent a clue why its throwing this error, code is used twice, first function works fine but the second one doesnt

Searched everywhere for posts on this error but none of them relate to what im trying to do

not the full code but whats important to this error

local NText = CreateFrame.Name
local IText = CreateFrame.Icon

local function enterIcon() --works
	IText.Text = IText.Text:gsub("%D", '');
	if IText.Text ~= "" then
		if not string.find(IText.Text, "rbxassetid://") then
			IText.Text = "rbxassetid://"..IText.Text
		end
	end
end

local function enterName() --doesnt work
	if NText.Text ~= "" then
		if string.len(NText.Text) > 25 then
			NText.Text = "25 characters maximum!"
		end
	end
end

IText.FocusLost:Connect(enterIcon)
NText.FocusLost:Connect(enterName) --error comes from here
2 Likes

What is the CreateFrame.Name?

This text will be blurred

1 Like
local GUI = script.Parent.Parent
local Main = GUI.Main
local CreateFrame = Main.CreateFrame
local NText = CreateFrame.Name
local IText = CreateFrame.Icon

image

The error could be occurring, because you use .Name, which is a property of every object. When saying CreateFrame.Name, you say “CreateFrame”.

3 Likes

Your problem is the Name TextButton. You can’t name objects a property name of it’s parent. Name is basically a property of every single object so I’d add a few more characters like FrameName.

2 Likes

oh my god, lack of sleep is getting to me :sob:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.