function updatetransparency(targ,bool) for i,v in pairs(targ:GetChildren()) do if…
- User
function updatetransparency(targ,bool) for i,v in pairs(targ:GetChildren()) do if v:IsA("Accessory") then updatetransparency(v,bool) elseif v:IsA("BasePart") then --HatAttachment FaceCenterAttachment HairAttachment NeckAttachment if v:FindFirstChild("HatAttachment") or v:FindFirstChild("FaceCenterAttachment") or v:FindFirstChild("FaceFrontAttachment") or v:FindFirstChild("FaceRearAttachment") or v:FindFirstChild("HairAttachment") or v:FindFirstChild("NeckAttachment") then if bool then v.LocalTransparencyModifier = 1 else v.LocalTransparencyModifier = v.Transparency end end end end end
function updatechartransparency(targ,bool) for i,v in pairs(targ:GetChildren()) do if v:IsA("BasePart") then if bool or v.Name == "Head" then v.LocalTransparencyModifier = 1 else v.LocalTransparencyModifier = v.Transparency end updatetransparency(v,bool) elseif v:IsA("Folder") or v:IsA("Model") then updatetransparency(v,bool) end end end
what do each of these do?
- Assistant
Let's break down each function to understand what they do:
updatetransparencyThis function takes two parameters:
targ(the target object) andbool(a boolean value). The function iterates through the children oftargand modifies theLocalTransparencyModifierfor certain parts and attachments based on the boolean value.-
Iteration through the children:
for i, v in pairs(targ:GetChildren()) do -
Checking for Accessory:
if v:IsA("Accessory") then updatetransparency(v, bool)- If the child
vis an "Accessory", the function calls itself recursively on that child and checks its descendants as well.
- If the child
-
Checking for BasePart:
elseif v:IsA("BasePart") then- If the child
vis a "BasePart", it looks for specific attachments (HatAttachment,FaceCenterAttachment,HairAttachment, etc.) on that part.
- If the child
-
Modifying LocalTransparencyModifier:
if v:FindFirstChild("HatAttachment") or v:FindFirstChild("FaceCenterAttachment") or v:FindFirstChild("FaceFrontAttachment") or v:FindFirstChild("FaceRearAttachment") or v:FindFirstChild("HairAttachment") or v:FindFirstChild("NeckAttachment") then if bool then v.LocalTransparencyModifier = 1 else v.LocalTransparencyModifier = v.Transparency end end- If one of the specified attachments is found,
LocalTransparencyModifieris set to1ifboolistrue, making the part fully transparent. Otherwise, it's set to the part's originalTransparency.
- If one of the specified attachments is found,
updatechartransparencyThis function also takes two parameters:
targ(the target character model or part) andbool(a boolean value). This function iterates through the children oftargand modifies theLocalTransparencyModifierfor every "BasePart" and its descendants, similar to the previous function, but also works with characters (models containing parts like "Head" and others).-
Iteration through the children:
for i, v in pairs(targ:GetChildren()) do -
Checking for BasePart:
if v:IsA("BasePart") then- If the child
vis a "BasePart", it checks ifboolistrueor if the part is named "Head".
- If the child
-
Modifying LocalTransparencyModifier:
if bool or v.Name == "Head" then v.LocalTransparencyModifier = 1 else v.LocalTransparencyModifier = v.Transparency end- If
boolistrueor the part is "Head", it sets theLocalTransparencyModifierto1. Otherwise, it reverts to the part's originalTransparency.
- If
-
Recursiveness:
updatetransparency(v, bool)- It calls
updatetransparencyto handle transparency for descendants of the current "BasePart".
- It calls
-
Checking for Folder or Model:
elseif v:IsA("Folder") or v:IsA("Model") then updatetransparency(v, bool) end- If the child
vis a "Folder" or "Model", it callsupdatetransparencyon it, ensuring that all sub-models and parts contained within are handled properly.
- If the child
Summary
updatetransparencyfocuses on updating transparency modifiers for specific parts and attachments within a given target object.updatechartransparencyis more comprehensive, as it handles transparency for entire character models, including additional parts like "Head" and ensuring all relevant descendent parts of both folders and models are also updated.
-