I'm making this script that has to change the value depending on what random number it lands on.
It has been working without the value part, but I'm not sure how to fix it
It also has an error saying:
EnumItem cannot be modified
This is the script:
local part = math.random(1,100)
local val = script.Parent.Material
print(part)
if part < 41 then
print("grass")
val.Value = "grass"
script.Parent.BrickColor = BrickColor.Green()
elseif part > 40 and part < 61 then
print("road")
val.Value = "road"
script.Parent.BrickColor = BrickColor.Black()
elseif part > 60 and part < 101 then
print("water")
val.Value = "water"
script.Parent.BrickColor = BrickColor.new("Bright bluish green")
end

3 comments
Enumerations have a Value property and your value object may be conflicting with the Material Enum, so try changing the name of your value object to something like "MatType" or "MaterialType" (without quotes).
Wow that actually worked!
You're welcome. :)