How do i localize v's Children?

so i’m trying to make it so V’s children become transparent as seen by this loop, but how would i localize the children?

for i, v in pairs(workspace:GetChildren()) do
			if v.Name == Player.Name then
				v:GetChildren() do
					v.Transparency = 1
					wait(duration)
					v.Tranparency = 0
						
					end
				end
			end
		end

Iterate through v’s children like you do for workspace:

for _, Child in ipairs(v:GetChildren()) do
    --// Code
end

Use ipairs for arrays by the way, it moves in a i++ order and in LuaU it’s optimised.


FYI: You can just access Player.Character instead of finding their character in Workspace.

1 Like

So is pairs and next. ipairs is idiomatically proper for iterating through contiguous arrays and it makes it more clear that what you’re iterating through is an array not a dictionary where the key matters. With ipairs, your keys are known to be incremental numerical indices starting from 1.

thanks for being epic although i was dumb and used :GetChildren() instead of :GetDescendants() since i wanted all the parts to be transparent.

edit: typo