Ok So i have an invisible power up but its not fully functional yet i want to have a for look look through the character to make every thing that can be Transparent = 100 to do so, Can someone help me simplify my code and learn to do a for loop like this? The current code i have cant make clothing or accessory invis
Here's my code :
local dad = script.Parent local function Invis(part) local p = part.Parent if game.Players:GetPlayerFromCharacter(p)then p.LeftFoot.Transparency = 100 p.LeftLowerLeg.Transparency = 100 p.LeftUpperLeg.Transparency = 100 p.LeftUpperArm.Transparency = 100 p.LeftLowerArm.Transparency = 100 p.LeftHand.Transparency = 100 p.RightHand.Transparency = 100 p.RightLowerLeg.Transparency = 100 p.RightFoot.Transparency = 100 p.RightUpperArm.Transparency = 100 p.RightLowerArm.Transparency = 100 p.RightUpperLeg.Transparency = 100 p.LowerTorso.Transparency = 100 p.UpperTorso.Transparency = 100 p.Head.Transparency = 100 p.Head.face.Transparency = 100 dad:Destroy() wait(10) p.LeftFoot.Transparency = 0 p.LeftLowerLeg.Transparency = 0 p.LeftUpperLeg.Transparency = 0 p.LeftUpperArm.Transparency = 0 p.LeftLowerArm.Transparency = 0 p.LeftHand.Transparency = 0 p.RightHand.Transparency = 0 p.RightLowerLeg.Transparency = 0 p.RightFoot.Transparency = 0 p.RightUpperArm.Transparency = 0 p.RightLowerArm.Transparency = 0 p.RightUpperLeg.Transparency = 0 p.LowerTorso.Transparency = 0 p.UpperTorso.Transparency = 0 p.Head.Transparency = 0 p.Head.face.Transparency = 0 end end dad.Touched:Connect(Invis) for doodoo =0 , 10 do wait(1) if doodoo == 10 then dad:Destroy() end end
In this kind of situation you need to loop through the body parts and check the part's Class the 2 Known classes that have the property Transparency are
1-MeshParts 2-Parts
We will have to use the for loop in maintaining the body parts and it can be implemented in the following code as i'll explain in big chunks of code;
Grabbing the user's Data/ Variables:
repeat wait() until game.Players:FindFirstChild("Divistern") local player = game.Players.Divistern repeat wait() until player.Character ~= nil local char = player.Character local perInvis = 10
Making the "Briefcase" for the player:
--Making a "briefcase" local playerBriefCase = Instance.new("Folder", game.ReplicatedStorage) playerBriefCase.Name = player.Name
Looping through body Parts and making them invisible:
for i,v in pairs(char:GetChildren()) do if v:IsA("Part") then --Making any "Part" invisible such as the "head" v.Transparency = 1 end if v:IsA("MeshPart") then --If the user is using any kind of a roblox package v.Transparency = 1 end if v:IsA("Accessory") then --If the user has any hats or accessories v.Parent = playerBriefCase end for i,x in pairs(char.Head:GetChildren()) do --To hide the face of the player if x:IsA("Decal") then if x.Name == "face" then x.Parent = playerBriefCase --Parenting the face in the player's "Briefcase" end end end end
Delaying:
wait(perInvis) --Delay between powers
Making Body Parts Visible and retrieving the accessories:
for _,Folder in pairs(game.ReplicatedStorage:GetChildren()) do --Getting the user's private folder if Folder.Name == player.Name then local briefCase = Folder for _,child in pairs(briefCase:GetChildren()) do --Retrieving the user's items if child:IsA("Decal") then if child.Name == "face" then child.Parent = char.Head end end if child:IsA("Accessory") then child.Parent = char end end end end for i,v in pairs(char:GetChildren()) do --Making user's body parts visible if v:IsA("Part") then if v.Name ~= "HumanoidRootPart" then v.Transparency = 0 end end if v:IsA("MeshPart") then v.Transparency = 0 end end
Full Overview:
Getting Variables
Looping through the body parts
Finding the user's "BriefCase" in ReplicatedStorage
Looping through the user's Character
Hope this helped. Sorry for any mistakes if there are, i was writing these while being sick.