Making models and tools with models transparent

completely new to scripting so i’m still learning the basics. i’m working on a simple cooking feature that relies on transparency. however, the script fails when trying to make the tool transparent:

RamenPack is not a valid member of Tool “Workspace.oddmy.RamenPack”

i also want to exclude some parts/meshes within the tool and the tool’s handle when later running a 0 transparency loop. what should i use to achieve these things?

hopefully this strange script won’t come back to haunt me haha… :slight_smile:

local cooking = script.Parent.Parent.RamenCook

script.Parent.Touched:Connect(function(Hit)
	if Hit.Parent.Name == 'RamenPack' then
		for i,v in pairs(cooking:GetDescendants()) do 
			if v:IsA("BasePart") or v:IsA("MeshPart") then
				v.Transparency = 1
			end
		end
		for i,v in pairs(Hit.Parent.RamenPack:GetDescendants()) do 
			if v:IsA("BasePart") or v:IsA("MeshPart") then
				v.Transparency = 1
			end
		end
1 Like

In your second for loop, it should be Hit.Parent instead since that is the ramen pack (im judging from the error you got)

yep that was the issue, thanks. how should i write the loop if i want to exclude certain models in the tool when doing v.Transparency = 0?

You could have a list of models that you want to blacklist when looking through

local Blacklist = {workspace.Duck,workspace.Car} -- Put your blacklisted models here

Then in your for loop…

for i,v in pairs(Hit.Parent:GetDescendants()) do
   if v:IsA('Model') and not table.find(Blacklist,v) then
      for i,v in pairs(v:GetDescendants()) do -- Since model does not have a transparency property, we need to loop through its parts
			if v:IsA("BasePart") or v:IsA("MeshPart") then
				v.Transparency = 1
			end
		end
   end
end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.