Calling a function gives weird error

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Let my script to work!
  2. What is the issue? Include screenshots / videos if possible!
    the error was
    Falcon_SB.Frame.MainLocalScript:523: attempt to call a string value
    Screen Shot 2564-05-23 at 8.37.21 AM|369x58
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    i tried replacing the function with the code and it worked, but when I use function it gives the error
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
function AutoComplete(AutoCompleteSelectionName, AutoCompleteSelectionType)
	local Indent = ""

	if AutoCompleteSelectionType == "Function" then
		Indent = "()"
	end

	Executor.CodeEditor.CodeBox.Text = Executor.CodeEditor.CodeBox.Text:gsub(Executor.CodeEditor.CodeBox.Text:match(Executor.CodeEditor.KeywordValue.Value .. "$"), AutoCompleteSelectionName .. Indent)

	RunService.Heartbeat:Wait()

	Executor.CodeEditor.CodeBox.SelectionStart = -1

	if Indent == "" then
		Executor.CodeEditor.CodeBox.CursorPosition = #Executor.CodeEditor.CodeBox.Text + 1
	else
		Executor.CodeEditor.CodeBox.CursorPosition = #Executor.CodeEditor.CodeBox.Text
	end

	Executor.CodeEditor.KeywordValue.Value = ""
	Executor.CodeEditor.CodeBox.AutoComplete.Visible = false
end

function CreateAutoCompleteSelection(AutoComplete, Type)
	local NewAutoCompleteSelection = AutoCompleteSelection:Clone()
	
	NewAutoCompleteSelection.Name = AutoComplete
	--NewAutoCompleteSelection.TextColor3 = Falcon_SB:GetAttribute(Type .. "Color3")
	NewAutoCompleteSelection.Text = "       " .. AutoComplete
	NewAutoCompleteSelection.ImageLabel.Image = Falcon_SB:GetAttribute(Type .. "Image")
	NewAutoCompleteSelection:SetAttribute("Type", Type)
	
	NewAutoCompleteSelection.Parent = Executor.CodeEditor.CodeBox.AutoComplete
	
	NewAutoCompleteSelection.Activated:Connect(function()
		AutoComplete(NewAutoCompleteSelection.Name, NewAutoCompleteSelection:GetAttribute("Type")) --This is the line that error
	end)
	
	NewAutoCompleteSelection.Visible = true
end

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

could you tell me what line 532 is?

1 Like

AutoComplete(NewAutoCompleteSelection.Name, NewAutoCompleteSelection:GetAttribute(“Type”))

tat was line 532, the line that error

he withdrawn the post everything is fine

1 Like

I kept getting this weird error, even when I change the parameters to object value, still get this error

Can’t you just reference it as an Instance…? You seem to have added a dot inbetween AutoCompleteSelection & Name

1 Like

I tried reference it as instance and still got the same error

Can you show us where you call CreateAutoCompleteSelection

1 Like

sure

spawn(function()
    for Index, AutoComplete in pairs(Keyword_AutoComplete) do
    	CreateAutoCompleteSelection(AutoComplete, "Keyword")
	end

    for Index, AutoComplete in pairs(Function_AutoComplete) do
	    CreateAutoCompleteSelection(AutoComplete, "Function")
    end

	for Index, AutoComplete in pairs(BuiltIn_AutoComplete) do
    	CreateAutoCompleteSelection(AutoComplete, "BuiltIn")
    end

    AutoCompleteSelectionList = Executor.CodeEditor.CodeBox.AutoComplete:GetChildren()
end)

hm very interesting everything seems to be fine

what do get if you put print statements

NewAutoCompleteSelection.Activated:Connect(function()
    print(AutoComplete) -- what does this print?
	AutoComplete(NewAutoCompleteSelection.Name, NewAutoCompleteSelection:GetAttribute("Type")) --This is the line that error
end)

Also can we see more of the error

1 Like

it printed ‘repeat’ when I click on repeat
and print ‘newproxy’ when I click on newproxy
basically It prints the text of the button I clicked

okay I know what’s happening, it’s not firing the function called AutoComplete, because there is a variable called autocomplete so it’s trying to “fire” that

when you say AutoComplete(), it think you are refering to the variable passed to the Create function, not the “AutoComplete” function

1 Like

I renamed the function AutoComplete to FillAutoComplete()
it works! tysm!!! :hearts:

1 Like

Oh this is why

You’re attempting to pass a parameter as a function, assuming that it’s a string value

You have to change your CreateAutoCompleteSelection function’s parameters to something else, maybe just:

function CreateAutoCompleteSelection(AutoCompleteName, Type)
1 Like

the issue is solved, also I did change and still same error, thanks anyway :smiley:

that makes a lot more sense now

1 Like