Answered by
4 years ago Edited 4 years ago
BrickColor is an Object since it contains methods, attributes, and more. Whereas Material is no more than a textual identifier that describes a to-be-used texture. It is not an Object, therefore lacks a constructor function.
By taking a quick look at the documentation of Material
, you'd notice it's an Enum
. You can use that to appropriately assign the property:
1 | BasePart.Material = Enum.Material. |
One last thing to mention: your loop has no yield, which, if you're fortunate, will cause a script-timeout. Make sure to include a wait()
somewhere in its scope.
NOTE:
You allocated the StringValue
s' values, which will actually store the state at which it was at runtime. You aren't creating a pointer to the property, nor can you ever. You'll need to index .Value
every time you wish to see its current state.
There is a much more efficient way of updating your property. Use the :GetPropertyChangedSignal() method of the Instance base-class. This will generate an RBXScriptSignal that you may bind a Callback to upon the suggested property's adjustment:
02 | local DropperModel = script.Parent |
04 | local DropPartTemplate = DropperModel.Part |
06 | local DropMaterial = DropperModel.DropMaterial |
07 | local DropColor = DropperModel.DropColor |
12 | DropMaterial:GetPropertyChangedSignal( "Value" ):Connect( function () |
13 | DropPartTemplate.Material = Enum.Material [ DropMaterial.Value ] |
16 | DropColor:GetPropertyChangedSignal( "Value" ):Connect( function () |
17 | DropPartTemplate.BrickColor = BrickColor.new(DropColor.Value) |