Attempt to index number

Hey developers!

I have a question.
I’m getting this error:

11:38:27.090 Players.iamajust.PlayerGui.Chat+.BubbleChat.MenuBackground.PropertyMenu.LocalScript:52: attempt to index number with ‘UserInput’ - Client - LocalScript:52

This is my script:

list.Transparency.UserInput.Changed:Connect(function()
	list.Transparency.UserInput.Text = string.gsub(list.Transparency.UserInput.Text, "[^%d%.]+", "")
	if tonumber(list.Transparency.UserInput.Text) > 1 then
		list.Transparency.UserInput.Text = "1"
	end

	preview.Frame.BackgroundTransparency = tonumber(list.Transparency.UserInput.Text)
end)

Any help will be appreciated!

Have a nice day.

1 Like

Which line is line 52? So I can see what exactly the error is

list.Transparency.UserInput.Changed:Connect(function() is line 52.

.Changed only works for ValueConstrained Instances like an Int Value. Instead use

list.Transparency.UserInput:GetPropertyChangedSignal("Text"):Connect(function()
1 Like

Script:

list.Transparency.UserInput:GetPropertyChangedSignal("Text"):Connect(function()
	list.Transparency.UserInput.Text = string.gsub(list.Transparency.UserInput.Text, "[^%d%.]+", "")
	if tonumber(list.Transparency.UserInput.Text) > 1 then
		list.Transparency.UserInput.Text = "1"
	end

	preview.Frame.BackgroundTransparency = tonumber(list.Transparency.UserInput.Text)
end)

Error:

12:09:56.394 Players.iamajust.PlayerGui.Chat+.BubbleChat.MenuBackground.PropertyMenu.LocalScript:52: attempt to index number with ‘UserInput’ - Client - LocalScript:52

:frowning:

Oh I see,
Why are you doing list.Transparency? Is it a frame?

The script is getting confused because Transparency is a property and a child

Rename Transparency to something else

Yes, list and list.Transparency are both a frame.

Isn’t it BackgroundTransparency though?

Edit after 2 minutes:
Wait, isn’t it a possibility to say list["Transparency"]?

Good point but just change the name to something else just in case it is the problem

Also could I have a look at your explorer to make sure you’re indexing stuff right

1 Like

Here:
Screenshot 26-01-2021 12.22.06

Screenshot 26-01-2021 12.23.53

Edit after 4 minutes:
Yes, this could also occur with BackgroundColor3 when I implement that into the script.

Renaming the frame to “RenamedProperty” still gave me the error.

Yeah, it’s because you frame name is the same as the frame property. If you’ve renamed it, you should be good.

iamajust Programmer

Renaming the frame to “RenamedProperty” still gave me the error.

Please read the posts first…

Edit after 3 minutes:
Nevermind… I tried it again and it works now.