Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i get the left arm of my character?

Asked by 5 years ago
Edited 5 years ago

I'm trying to make my characters left arm turn neon but it keeps saying " 00:04:41.981 - LeftArm is not a valid member of Model"

So how do i select my characters left arm?

I'm using R6

local players = game.Players.LocalPlayer
local character = players.Character
local UIS = game:GetService("UserInputService")

UIS.InputBegan:Connect(function(key)
    if key.KeyCode == Enum.KeyCode.T then
        character.LeftArm.Material = Enum.Material.Neon
    end
end)

2 answers

Log in to vote
5
Answered by
Thernus 75
5 years ago
Edited 5 years ago

Hey! This seems like an issue because you are referring to a part that does not exist on R15 avatars. If you are using R6, just let me know and I can try to figure out the issue from there.

When Roblox changed to R15, it turned both arms into 3 separate parts to allow for more freedom with animation. These parts are LeftUpperArm, LeftLowerArm, and LeftHand.

To make the entire left arm neon, you can do this:

local players = game.Players.LocalPlayer
local character = players.Character
local UIS = game:GetService("UserInputService")

UIS.InputBegan:Connect(function(key)
    if key.KeyCode == Enum.KeyCode.T then
        character["LeftUpperArm"].Material = Enum.Material.Neon
        character["LeftLowerArm"].Material = Enum.Material.Neon
        character["LeftHand"].Material = Enum.Material.Neon
    end
end)

EDIT: As you are using R6, this issue is because there is a space in "Left Arm".

To refer to an object with a space, you should use character["Left Arm"] as opposed to character.Left Arm.

local players = game.Players.LocalPlayer
local character = players.Character
local UIS = game:GetService("UserInputService")

UIS.InputBegan:Connect(function(key)
    if key.KeyCode == Enum.KeyCode.T then
        character["Left Arm"].Material = Enum.Material.Neon
    end
end)

0
Best tutorial I ever seen. Upvoted immediately without thinking. Xapelize 2658 — 5y
0
I'm using R6 Jiro_Snake 4 — 5y
0
Edited to include what would work for R6 Thernus 75 — 5y
Ad
Log in to vote
2
Answered by 5 years ago
Edited 5 years ago

Thernus's Answer is pretty straight forward except for the fact that what if you wanted to use R6 and R15?

Thernus is not wrong in any sort of way I am just going to show you what you can incorporate for improvement a humanoid has a property called RigType you can actually detect if they are either R6 or R15 and you would do it like this

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()

-- Have this inside your inputbegan
local humanoid = character:FindFirstChild("Humanoid")
if humanoid then
    if humanoid.RigType == Enum.HumanoidRigType.R6 then -- Is a R6 character.
        -- Assign variables to the body parts in R6; do desired task
    elseif humanoid.RigType == Enum.HumanoidRigType.R15 then -- Is a R15 character.
        -- Assign variables to the body parts in R15; do desired task
    end
end

RigType

Enum reference

If this helped an upvote or solved would be greatly appreciated. Good luck!

  • Best Regards, -Syn
0
Great thinking! I completely forgot some games use both R6 and R15. Thernus 75 — 5y

Answer this question