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

[Help] "MSG is not a valid member of Workspace" what?

Asked by 5 years ago

The code is for a color move game but when I try to run it I got this "MSG is not a valid member of Workspace" but I set MSG to Workspace please help.

---- Locals
local blue = game.Workspace.Model.Blue
local red = game.Workspace.Model.Red
local green = game.Workspace.Model.Green
local yellow = game.Workspace.Model.Yellow

---- Main Code
while true do
    wait(1)
    idkmath = math.random(1, 4)
    if idkmath == 1 then --- bule
        MSG = Instance.new("Message")
        MSG.Parent = game.Workspace
        MSG.Text = ("GO to bule")
        wait(1)
        game.Workspace.MSG:Remove()
        wait(1)
        red.CanCollide = false
        green.CanCollide = false
        yellow.CanCollide = false
    elseif  idkmath == 2 then --- red
        MSG = Instance.new("Message")
        MSG.Parent = game.Workspace
        MSG.Text = ("GO to red")
        wait(1)
        game.Workspace.MSG:Remove()
        wait(1)
        blue.CanCollide = false
        green.CanCollide = false
        yellow.CanCollide = false
    elseif  idkmath == 3 then --- green
        MSG = Instance.new("Message")
        MSG.Parent = game.Workspace
        MSG.Text = ("GO to green")
        wait(1)
        game.Workspace.MSG:Remove()
        wait(1)
        blue.CanCollide = false
        red.CanCollide = false
        yellow.CanCollide = false
    else if idkmath == 4 then
        MSG = Instance.new("Message")
        MSG.Parent = game.Workspace
        MSG.Text = ("GO to yellow")
        wait(1)
        game.Workspace.MSG:Remove()
        wait(1)
        blue.CanCollide = false
        green.CanCollide = false
        red.CanCollide = false
        end
    end
end
0
what line is this erroring at? ArtBlart 533 — 5y
0
oh nvm, the answer below is what you need ArtBlart 533 — 5y

1 answer

Log in to vote
1
Answered by
cfiredog 274 Moderation Voter
5 years ago

Replace game.Workspace.MSG:Remove() on line 16, 26, 36, and 46 with:

MSG:Remove()

When creating a new message instance, the instance's name is set by default to "Message", so looking for "MSG" in the workspace will not find the message. You had already created a variable that has a reference to the message, so you can just use the variable rather than looking for it in the workspace.

0
:O thx bic_round 9 — 5y
Ad

Answer this question