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

Not a Valid Member of model..?

It says "Pan.Tilt.Mesh" is not a valid member of model?

local dir = "Pan.Tilt.Mesh";
local mac ={workspace.Mac1,workspace.Mac2,workspace.Mac3,workspace.Mac4,workspace.Mac5,workspace.Mac6,workspace.Mac7,workspace.Mac8}

function Clicked()
	if script.Parent.Bool.Value == false then
		for i,v in pairs(mac) do
		v[dir].Transparency = v[dir].Transparency + 0.5
		script.Parent.Bool.Value = true
	end
	end
	end
script.Parent.MouseButton1Down:connect(Clicked)

2 comments

0

Is the name of the instances "Pan.Tilt.Mesh" or is that the location of it inside one of the Mac's?

0

It goes "game.Workspace.Mac1.Pan.Tilt.Mesh" same for all the other macs.

1 answer

With string.gmatch you can get the location with the string as shown below.

local dir = "Pan.Tilt.Mesh";
local mac ={workspace.Mac1,workspace.Mac2,workspace.Mac3,workspace.Mac4,workspace.Mac5,workspace.Mac6,workspace.Mac7,workspace.Mac8}

function Clicked()
    if script.Parent.Bool.Value == false then
        for i,v in pairs(mac) do
		local d = v
		for k in dir:gmatch('[^.]+') do
			d = d[k]
		end
        d.Transparency = d.Transparency + 0.5
        script.Parent.Bool.Value = true
    end
    end
    end
script.Parent.MouseButton1Down:connect(Clicked)

10 comments

0

Error : Workspace.Screen2.Screen.SurfaceGui.Frame.MacBeams.AllOn.Script:9: 'do' expected near 'd'

0

Oops, forgot the do after gmatch(), fixed.

0

Error : P is not a valid member of Model

0

Sorry, the + goes outside of the []'s, I should really start verifying that I have not made a typo... (fixing)

0

Okay, just let me know when you check everything.

0

I did do it that time, as long as the dir value is correct, it should work, otherwise it will just throw the "Not a Valid Member" error

0

Well, same thing happened again... Error : Pan.Tilt.Mesh is not a valid member of Part

0

This is what it looks like in workspace.. http://prntscr.com/7zbkr6

0

Sorry for not testing properly, I do not commonly post on here and forget to test, I tested the pattern not the entire thing, I did not remove the [dir].

0

Transparency is not a valid member of model...

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