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

How do I select a body part from the table?

local BodyParts = {h.Parent["Right Arm"], h.Parent["Left Arm"], h.Parent.Torso, h.Parent["Left Leg"], h.Parent["Right Leg"]}
local BodyPart  = BodyParts(math.random(1, 5))

I know I'm doing this wrong so please help me.

1 answer

✓ Accepted answer

You almost have it. All you need to change is the way you're trying to access the table. You're attempting to do so with parentheses. To access a table you need to use brackets. So, your code should look like this:

local BodyParts = {h.Parent["Right Arm"], h.Parent["Left Arm"], h.Parent.Torso, h.Parent["Left Leg"], h.Parent["Right Leg"]}
local BodyPart  = BodyParts[math.random(1, 5)]

Anyways, that's it. If you have any further problems/questions, please leave a comment below and I'll see what I can do. Hope I helped :P

####-Dyler3

2 comments

0

Thanks for the fastest response in my ScriptHelpers history

0

Lol no problem. Glad I could help :P

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