I am a new developer trying to make an obby. recently i had the the idea to make a tool that turns all transparency parts red and and visible, and back when the tool is not being held. please help. it has mainly been ripped from the roblox dev site and im trying to not show parts with scripts in them

local tool = script.Parent
 
local function onEquip()


 tool.Equipped:Connect(onEquip)
local function makeXRayPart(part)
	
	part.LocalTransparencyModifier = 0 
end
 

local function recurseForParts(object)
	
	if object:IsA("BasePart") then
		makeXRayPart(object)
	end
	
 
	if object.Transparency == 1 then
	if object:IsA("Script") or object:IsA("LocalScript") then return end
end
	for _, child in pairs(object:GetChildren()) do
		recurseForParts(child)
	end
if object:FindFirstChildOfClass("LocalScript") or
 object:FindFirstChildOfClass("Script") then return end
end

 
recurseForParts(workspace)

end

2 comments

0

i diddn't write the changing back into transparrent as it is essentially the same

0

You need to write a loop to get all the parts in the workspace. Basically what you are telling it is to change the transparency of workspace itself and not the parts inside of it.