Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

2 comments

0

what line is this erroring at?

0

oh nvm, the answer below is what you need

1 answer

✓ Accepted answer

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.

1 comment

0

:O thx

This discussion is preserved as it was. New answers, comments, and votes are closed.