Help with FNaF Help Wanted Gallery Menu script

I want a script that makes one model appear while the others are invisible within a folder, similar to how it works in FNaF Help Wanted. (FNaF Help Wanted I All Characters in Gallery - YouTube)

The script for some reason runs in a loop and no models appear, they’re all invisible and it constantly gives out prints infinitely and it doesn’t actually end ever. I’m really confused as to why this is happening.
infinite

I’ve asked others for help and nobody really has any idea what’s happening to cause this. Any additional help would be fantastic.

Here’s the script if anyone is curious about it.

local button = workspace.GalleryMonitor1.Screen.Icons

function Swap(modeltoappear)
	modeltoappear = workspace:WaitForChild("GalleryModels")
	for i,v in pairs (workspace.GalleryModels:GetDescendants()) do
		if v.Name ~= modeltoappear.Name then
			for i,v in pairs(workspace.GalleryModels:GetDescendants()) do
				wait()
				if v:IsA("Texture") then
					v.Transparency = 1
					print("11")
				end
				if v:IsA("Decal") then
					v.Transparency = 1
					print("15")
				end
				if v:IsA("UnionOperation") then
					v.Transparency = 1
					print("19")
				end
				if v:IsA("Part") then
					v.Transparency = 1
					print("23")
				end
			end
		else
			for i,v in pairs(workspace.GalleryModels:GetDescendants()) do
				wait()
				if v:IsA("Texture") then
					v.Transparency = 0
					print("25")
				end
				if v:IsA("Decal") then
					v.Transparency = 0
					print("35")
				end
				if v:IsA("UnionOperation") then
					v.Transparency = 0
					print("39")
				end
				if v:IsA("Part") then
					v.Transparency = 0
					print("43")
				end
			end
		end
	end
end

button.Frame.FreddyFazbear.MouseButton1Click:Connect(function()
	print("ok")
	local modelSwap = script.Parent
	Swap(modelSwap.Name)
end)
1 Like
local button = workspace.GalleryMonitor1.Screen.Icons

function Swap(modeltoappear)
	for i,v in pairs (workspace.GalleryModels:GetDescendants()) do
		if v.Name ~= modeltoappear.Name then
			for i,v in pairs(workspace.GalleryModels:GetDescendants()) do
				wait()
				if v:IsA("Texture") then
					v.Transparency = 1
					print("11")
				end
				if v:IsA("Decal") then
					v.Transparency = 1
					print("15")
				end
				if v:IsA("UnionOperation") then
					v.Transparency = 1
					print("19")
				end
				if v:IsA("Part") then
					v.Transparency = 1
					print("23")
				end
			end
		else
			for i,v in pairs(workspace.GalleryModels:GetDescendants()) do
				wait()
				if v:IsA("Texture") then
					v.Transparency = 0
					print("25")
				end
				if v:IsA("Decal") then
					v.Transparency = 0
					print("35")
				end
				if v:IsA("UnionOperation") then
					v.Transparency = 0
					print("39")
				end
				if v:IsA("Part") then
					v.Transparency = 0
					print("43")
				end
			end
		end
	end
end

button.Frame.FreddyFazbear.MouseButton1Click:Connect(function()
	print("ok")
	local modelSwap = script.Parent
	Swap(modelSwap.Name)
end)

still runs within a infinite loop for some reason

Could you share with us the structure of your folder, for myself doesn’t seem really smart to do a nested loop within the same loop which you’re already iterating. :thinking: (GetDescendants already gets all the instances under that parent Instance).

When I mean share the structure, I mean a screenshot of the GalleryModels and within (expanded).

Oh, mb lemme get the screenshot

here’s the way the folder works

thing

And what is the structure of the models? From this you can already change the first loop to just works.GalleryModels:GetChildren().

1 Like

this is the structure, it’s a bunch of unions with some parts

also yeah, lemme try that rq

parts

1 Like

image

Also this part doesn’t make any sense, you’re reassigning the modeltoappear to the folder, which name will be GalleryModels. :thinking:

This won’t work at all.

1 Like

ohhh, should i assign it to all of the children?

No, I just want to understand what you’re doing and what you’re writing, at the moment it doesn’t make any sense at all, could we take up this discussiong to Discord if you have any? Real-time communication would be faster.

Here it is: SiriusLatte#2024

1 Like

yeah, i’ll add you rq

my username is biggest snooker fan so you don’t get confused

Were you ever able to fix the script? If so, would you mind making it open-sourced??