Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Beautify a piece of code?

I've this code:

local Character = plr.Character
Character.Head.Transparency= .7
Character.UpperTorso.Transparency= .7
Character.LowerTorso.Transparency= .7
Character.LeftUpperArm.Transparency= .7
Character.LeftLowerArm.Transparency= .7
Character.LeftHand.Transparency= .7
Character.RightUpperArm.Transparency= .7
Character.RightLowerArm.Transparency= .7
Character.RightHand.Transparency= .7
Character.LeftUpperLeg.Transparency= .7
Character.LeftLowerLeg.Transparency= .7
Character.LeftFoot.Transparency= .7
Character.RightUpperLeg.Transparency= .7
Character.RightLowerLeg.Transparency= .7
Character.RightFoot.Transparency= .7

Is it possible to commute this for example to:

local r15parts = {"Head", "UpperTorso", "LowerTorso", "RightUpperArm", "RightLowerArm", "LeftUpperArm", "LeftLowerArm", "RightUpperLeg", "RightLowerLeg", "LeftUpperLeg", "LeftLowerLeg", "RightHand", "LeftHand", "RightFoot", "LeftFoot"}

for _, v in pairs (r15parts) do
    Character.v.Transparency = .7
end

1 answer

✓ Accepted answer

You don't even need the list at all.

for i, v in pairs(game.Players.LocalPlayer.Character:GetChildren()) do
	if v:IsA("Part") or v:IsA("MeshPart") or v:IsA("BasePart") then
		v.Transparency = 0.7
	end
end

This discussion is preserved as it was. New answers, comments, and votes are closed.