Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

EnumItem cannot be modified? [closed]

Asked by 9 years ago

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
2
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). Spongocardo 1991 — 9y
0
Wow that actually worked! SpazzMan502 133 — 9y
0
You're welcome. :) Spongocardo 1991 — 9y

Locked by Spongocardo, chess123mate, and M39a9am3R

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?