X is not a valid member of Model "Workspace.Model"

So I want a script that colors the part in Model white.


The problem is that, it thinks that x is not an input, but a child of Model!

I don’t know any solutios! So can you please help?

Code and error:

function on(x)

--20:33:49.893  x is not a valid member of Model "Workspace.Model"  -  Server - Script:10
1 Like

I’m not sure but i guess x is the name of the part? If so then you could do


If the “x” you send is a Part instance, then just do:

function on(x)
	if x:IsDescendantOf(game.Workspace.Model) then

We use “IsDescendantOf()” to make sure the player don’t send another part that should not be colored,

When you index for x, it is attempting to index a child of the model named x – you would want to use square brackets [] for this to work correctly, since that would allow you to index with the inputted string.

function on(name) -- formery "x"
    game.Workspace.Model[name].BrickColor = BrickColor.White()

If your “x” is a Part’s name and not an Instance and you use the solution above, be aware that in your case (Where you have 16 parts named the same, ‘0’) it will only change the color of one of them and most likely the top one in the explorer at that time.