Alright so I have this script that is supposed to loop through a folder and if it finds a descendant that has a specific names it gives it pathways to global parts (ViewPart, Icon, etc) and ViewPart is causing problems here. The error says it isn’t a valid member of BillboardGui even though it is in a model.
for i, v in pairs(WorkingMonitors:GetDescendants()) do
if v.Name == "MonitorOrder" then
local PlayerViewPart = v.Parent.ViewPart
local Icon = v.Parent.ExampleMonitor.MonitorProxTemplate
There could be something named similarly inside the MonitorProxTemplate BillboardGui since you are looping through every descendant of the folder, making it pass the name check and try to access ViewPart (which doesn’t exist there, giving the error)
You may be referring to BillboardGui instead of Monitor1 in your variable. You can also try making it so this script loops through each individual Monitor (Monitor1, Monitor 2, e.g.)
I can safely say that it is because of the fact that you’re basically looking for a non-existent instance.
Here is the code:
for i, monitor in pairs(WorkingMonitors:GetDescendants()) do
local MonitorName = tostring("Monitor" .. i)
if monitor.Name == MonitorName then
for i, v in pairs(monitor:GetDescendants()) do
if v.Name == "MonitorOrder" then
local PlayerViewPart = monitor.ViewPart
local Icon = monitor.ExampleMonitor.MonitorProxTemplate
end
end
end
Let me know if I have made a mistake since I’ve written a code without using studio to check if it’s correct.