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

Trying to print a list of parts with a generic for yielded unexpected results?

I wanted to make a script that would print out the parts of the Player's RigType for fun. When I made my avatar R6, everything worked like a charm, however, when I printed out the contents of the R15 parts, I got this:

HumanoidRootPart (x2) LeftHand HumanoidRootPart LeftHand LeftLowerArm HumanoidRootPart LeftHand LeftLowerArm LeftUpperArm HumanoidRootPart LeftHand LeftLowerArm LeftUpperArm RightHand HumanoidRootPart LeftHand LeftLowerArm LeftUpperArm RightHand RightLowerArm HumanoidRootPart LeftHand LeftLowerArm LeftUpperArm RightHand RightLowerArm RightUpperArm HumanoidRootPart LeftHand LeftLowerArm LeftUpperArm RightHand RightLowerArm RightUpperArm UpperTorso HumanoidRootPart LeftHand LeftLowerArm LeftUpperArm RightHand RightLowerArm RightUpperArm UpperTorso LeftFoot HumanoidRootPart LeftHand LeftLowerArm LeftUpperArm RightHand RightLowerArm RightUpperArm UpperTorso LeftFoot LeftLowerLeg HumanoidRootPart LeftHand LeftLowerArm LeftUpperArm RightHand RightLowerArm RightUpperArm UpperTorso LeftFoot LeftLowerLeg LeftUpperLeg HumanoidRootPart LeftHand LeftLowerArm LeftUpperArm RightHand RightLowerArm RightUpperArm UpperTorso LeftFoot LeftLowerLeg LeftUpperLeg RightFoot HumanoidRootPart LeftHand LeftLowerArm LeftUpperArm RightHand RightLowerArm RightUpperArm UpperTorso LeftFoot LeftLowerLeg LeftUpperLeg RightFoot RightLowerLeg HumanoidRootPart LeftHand LeftLowerArm LeftUpperArm RightHand RightLowerArm RightUpperArm UpperTorso LeftFoot LeftLowerLeg LeftUpperLeg RightFoot RightLowerLeg RightUpperLeg HumanoidRootPart LeftHand LeftLowerArm LeftUpperArm RightHand RightLowerArm RightUpperArm UpperTorso LeftFoot LeftLowerLeg LeftUpperLeg RightFoot RightLowerLeg RightUpperLeg LowerTorso HumanoidRootPart LeftHand LeftLowerArm LeftUpperArm RightHand RightLowerArm RightUpperArm UpperTorso LeftFoot LeftLowerLeg LeftUpperLeg RightFoot RightLowerLeg RightUpperLeg LowerTorso HumanoidRootPart LeftHand LeftLowerArm LeftUpperArm RightHand RightLowerArm RightUpperArm UpperTorso LeftFoot LeftLowerLeg LeftUpperLeg RightFoot RightLowerLeg RightUpperLeg LowerTorso Head HumanoidRootPart LeftHand LeftLowerArm LeftUpperArm RightHand RightLowerArm RightUpperArm UpperTorso LeftFoot LeftLowerLeg LeftUpperLeg RightFoot RightLowerLeg RightUpperLeg LowerTorso Head HumanoidRootPart LeftHand LeftLowerArm LeftUpperArm RightHand RightLowerArm RightUpperArm UpperTorso LeftFoot LeftLowerLeg LeftUpperLeg RightFoot RightLowerLeg RightUpperLeg LowerTorso Head HumanoidRootPart LeftHand LeftLowerArm LeftUpperArm RightHand RightLowerArm RightUpperArm UpperTorso LeftFoot LeftLowerLeg LeftUpperLeg RightFoot RightLowerLeg RightUpperLeg LowerTorso Head HumanoidRootPart LeftHand LeftLowerArm LeftUpperArm RightHand RightLowerArm RightUpperArm UpperTorso LeftFoot LeftLowerLeg LeftUpperLeg RightFoot RightLowerLeg RightUpperLeg LowerTorso Head HumanoidRootPart LeftHand LeftLowerArm LeftUpperArm RightHand RightLowerArm RightUpperArm UpperTorso LeftFoot LeftLowerLeg LeftUpperLeg RightFoot RightLowerLeg RightUpperLeg LowerTorso Head HumanoidRootPart LeftHand LeftLowerArm LeftUpperArm RightHand RightLowerArm RightUpperArm UpperTorso LeftFoot LeftLowerLeg LeftUpperLeg RightFoot RightLowerLeg RightUpperLeg LowerTorso Head

I apologize for that wall. Anyways, I didn't really know what to do but I still attempted to fix it; I tried to change the ipairs to in pairs on lines 13 and 17 but nothing changed, and I also attempted to check if "r15" was a MeshPart instead of a BasePart but to no avail.

I would appreciate the help! :)

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local body = {}

if hum.RigType == Enum.HumanoidRigType.R6 then
	for _,r6 in ipairs(char:GetChildren()) do
		if r6:IsA("BasePart") then
			table.insert(body,r6)
		end
	end
elseif hum.RigType == Enum.HumanoidRigType.R15 then
	for _,r15 in ipairs(char:GetChildren()) do
		if r15:IsA("BasePart") then
			table.insert(body,r15)
		end
		for _,pr15 in ipairs(body) do
			print(pr15)
		end
	end
end

1 answer

Move your print statement out of the for loop that is looking through the character, like so

elseif hum.RigType == Enum.HumanoidRigType.R15 then
	for _,r15 in ipairs(char:GetChildren()) do
		if r15:IsA("BasePart") then
			table.insert(body,r15)
		end
	end

	for _,pr15 in ipairs(body) do
		print(pr15)
	end
end

2 comments

0

Oh I didn't notice, that worked thank you so much! :)

0

Not a problem

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