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
1 | local players = game.Players.LocalPlayer |
2 | local character = players.Character |
3 | local UIS = game:GetService( "UserInputService" ) |
4 |
5 | UIS.InputBegan:Connect( function (key) |
6 | if key.KeyCode = = Enum.KeyCode.T then |
7 | character.LeftArm.Material = Enum.Material.Neon |
8 | end |
9 | end ) |
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:
01 | local players = game.Players.LocalPlayer |
02 | local character = players.Character |
03 | local UIS = game:GetService( "UserInputService" ) |
04 |
05 | UIS.InputBegan:Connect( function (key) |
06 | if key.KeyCode = = Enum.KeyCode.T then |
07 | character [ "LeftUpperArm" ] .Material = Enum.Material.Neon |
08 | character [ "LeftLowerArm" ] .Material = Enum.Material.Neon |
09 | character [ "LeftHand" ] .Material = Enum.Material.Neon |
10 | end |
11 | 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
.
1 | local players = game.Players.LocalPlayer |
2 | local character = players.Character |
3 | local UIS = game:GetService( "UserInputService" ) |
4 |
5 | UIS.InputBegan:Connect( function (key) |
6 | if key.KeyCode = = Enum.KeyCode.T then |
7 | character [ "Left Arm" ] .Material = Enum.Material.Neon |
8 | end |
9 | end ) |
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
01 | local player = game.Players.LocalPlayer |
02 | local character = player.Character or player.CharacterAdded:Wait() |
03 |
04 | -- Have this inside your inputbegan |
05 | local humanoid = character:FindFirstChild( "Humanoid" ) |
06 | if humanoid then |
07 | if humanoid.RigType = = Enum.HumanoidRigType.R 6 then -- Is a R6 character. |
08 | -- Assign variables to the body parts in R6; do desired task |
09 | elseif humanoid.RigType = = Enum.HumanoidRigType.R 15 then -- Is a R15 character. |
10 | -- Assign variables to the body parts in R15; do desired task |
11 | end |
12 | end |
If this helped an upvote or solved would be greatly appreciated. Good luck!