Add error for when trying to set an Instance to a non-Instance

I’m a bit of an idiot, so sometimes I forget to e.g type out the property name after the instance name when trying to set a property.

So e.g instead of Interface.UICorner.CornerRadius = UDim.new() I accidentally do Interface.UICorner = UDim.new(), and I was really wondering why the instance no longer existed until I realized that I was setting the instance- instead of the property to a UDim.

So I would appreciate an error like Attempt to convert Instance to UDim.

1 Like

To clarify, are you asking that we add a better error message than the one that exists now:

local f = Instance.new("Folder")
Instance.new("UICorner").Parent = f
f.UICorner = UDim.new()

-- ERROR: UICorner is not a valid member of Folder "Folder"

No. What I did wrong before was that I was trying to modify the CornerRadius property of a UICorner, but instead of typing Frame.UICorner.CornerRadius = UDim.new() I wrongly typed Frame.UICorner = Udim.new() which meant that any future reference to Frame.UICorner was throwing a “UICorner is not a valid member of xxx” error because the UICorner itself was mistakenly set to a UDim, so it was no longer an instance. And I spent too long trying to figure out what I had done wrong, but if there was an error that told me that I was trying to “convert” an instance to a UDim, that would’ve been very helpful.

What you are describing, being able to do Frame.UICorner = UDim.new(), is not possible; I think you are mistaken on what happened.

Can you create a small repro case?

Ah, I misunderstood what happened - but the error is still wrong.

This is the code I am using:

while task.wait(2) do
	script.Parent.ScreenGui.Frame.UICorner = UDim.new(1, 0)
end

And I get the error UICorner is not a valid member of Frame "Players.Pismyren.PlayerGui.ScreenGui.Frame" every 2 seconds.


As you can see here, it is a valid member though, so the error likely comes from me trying to convert it into a non-instance.

Right, that’s what I meant before with my original comment. I agree that the error message can be improved.

1 Like