How would i get specific items from a table?

i need to get the left and right shoulder (motor6d) from my table bptable. i want to return both the left and right shoulder and then print the m6d name if that makes sense. the problem is is that it’s printing only “LeftLowerArm” and idk what im doing wrong. i appreciate any help ty!!

local bpTable = {
	Head = 	c:WaitForChild("Head"),
	RightHand = c:WaitForChild("RightHand"),
	LeftHand = c:WaitForChild("LeftHand"),
	LowerTorso = c:WaitForChild("LowerTorso"),
	RightLowerArm = c:WaitForChild("RightLowerArm"),
	LeftUpperArm = c:WaitForChild("LeftUpperArm"),
	LeftLowerArm = c:WaitForChild("LeftLowerArm"),
	RightUpperArm = c:WaitForChild("RightUpperArm"),
	UpperTorso = c:WaitForChild("UpperTorso"),
	RightShoulder = c:WaitForChild("RightUpperArm"):WaitForChild("RightShoulder");
	LeftShoulder = c:WaitForChild("LeftUpperArm"):WaitForChild("LeftShoulder");
	RightElbow = c:WaitForChild("RightLowerArm"):WaitForChild("RightElbow");
	LeftElbow = c:WaitForChild("LeftLowerArm"):WaitForChild("LeftElbow")
}

local function getShoulders()
	
repeat wait()
until workspace:FindFirstChild(c.Name)

if c then
	print("found ".. c.Name)
end

	for _, m6d in pairs(bpTable) do
		if m6d == bpTable.LeftShoulder or bpTable.RightShoulder then
			return m6d
		end
	end
end

print(getShoulders())

output:
image

Idk if this is what you mean, but you could just do this:

for i, m6d in pairs(bpTable) do
		if i == "LeftShoulder" or i == "RightShoulder" then
			return m6d
		end
	end
2 Likes

thats exactly what i wanted mate, thanks a million man have a great day and thank u for helping me :slight_smile:

solution:

local bpTable = {
	Head = 	c:WaitForChild("Head"),
	RightHand = c:WaitForChild("RightHand"),
	LeftHand = c:WaitForChild("LeftHand"),
	LowerTorso = c:WaitForChild("LowerTorso"),
	RightLowerArm = c:WaitForChild("RightLowerArm"),
	LeftUpperArm = c:WaitForChild("LeftUpperArm"),
	LeftLowerArm = c:WaitForChild("LeftLowerArm"),
	RightUpperArm = c:WaitForChild("RightUpperArm"),
	UpperTorso = c:WaitForChild("UpperTorso"),
	RightShoulder = c:WaitForChild("RightUpperArm"):WaitForChild("RightShoulder");
	LeftShoulder = c:WaitForChild("LeftUpperArm"):WaitForChild("LeftShoulder");
	RightElbow = c:WaitForChild("RightLowerArm"):WaitForChild("RightElbow");
	LeftElbow = c:WaitForChild("LeftLowerArm"):WaitForChild("LeftElbow")
}

local function getShoulders()

	repeat wait()
	until workspace:FindFirstChild(c.Name)

	if c then
		print("found ".. c.Name)
	end

	for i, v in pairs(bpTable) do
		if i == "LeftShoulder" or i == "RightShoulder" then
			print(i.." = "..v.Name)
			return v
		end
	end
end

getShoulders()
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.