hello everyone I have a simple problem that I can’t solve I’m creating a hidecharacter function like this
local function hideCharacter(Character, Value)
coroutine.wrap(function()
for i, v in pairs(Character:GetDescendants()) do
if v:IsA("MeshPart") or v:IsA("BasePart") or v:IsA("Decal") then
if v.Name ~= "HumanoidRootPart" then
v.Transparency = Value
end
end
end
end)()
end
but there is one basepart of the character that I added myself for certain functions that are invisible and not at certain times but because of this function the baseparts that I added myself are now not invisible anymore,
I tried using :GetChildren()
but the transparent ones are only the base part of the body and no other accessories, do you know
how to solve it?
You can put a table containing the parts you don’t want to be affected and ignore it if it gets to the unwanted parts (if the table refers to actual parts in the character, remove the .Name from if v.Name == UPart.Name then)
local UnwantedParts = {} -- put parts not be affected by function here
local function hideCharacter(Character, Value)
coroutine.wrap(function()
for i, v in pairs(Character:GetDescendants()) do
if v:IsA("MeshPart") or v:IsA("BasePart") or v:IsA("Decal") then
local skip = false
for _,UPart in pairs(UnwantedParts) do -- loop through Unwanted parts
if v.Name == UPart.Name then
skip = true -- signal to skip if found
break
end
end
if skip == true then continue end -- advance to next part if part found in unwanted table
if v.Name ~= "HumanoidRootPart" then
v.Transparency = Value
end
end
end
end)()
end