FocusLost is not a valid member of textbox. Glitch?

I have a group of textboxes that I was trying to code to be more effecient by placing all 6 of their focuslost functions into a for loop to save space. But for some odd reason it doesn’t register the textbox.FocusLost event when it’s used within a for loop. Do I need to just write out all 6 individually or am I doing something wrong.

local mytextbox = CustonNames.S

mytextbox.FocusLost:Connect(function()
print(“FunctionWorked”)
-----This Works
end)

for i, Textbox in pairs(CustonNames:GetChildren()) do
Textbox.FocusedLost:Connect(function()
TierNameChanged:FireServer(Textbox.Name, Textbox.Text)

end)

end

The Error I get for the for loop:

FocusedLost is not a valid member of TextBox “Players.CalebHbk10.PlayerGui.Screen.CustomNames.S” - Client - CustomTierNames:58

You misspelled FocusLost as FocusedLost

You misspelled the event name, this is how your code should look like:

for i, Textbox in pairs(CustonNames:GetChildren()) do
  Textbox.FocusLost:Connect(function()
    TierNameChanged:FireServer(Textbox.Name, Textbox.Text)
  end)
end

Whoops thats embarrasing. Thank you.

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