I am trying to set all players character parts to a certain size. Its not working.
player = game.Players.LocalPlayer CharParts = {"Right Arm", "Right Leg", "Left Arm", "Left Leg", "Head", "Torso"} player.Character.CharParts[1].Size = Vector3.new(0.4, 0.8, 0.4) player.Character.CharParts[2].Size = Vector3.new(0.4, 0.8, 0.4) player.Character.CharParts[3].Size = Vector3.new(0.4, 0.8, 0.4) player.Character.CharParts[4].Size = Vector3.new(0.4, 0.8, 0.4)
This is how you for loop it
EDIT: Admins want me to explain my code.
Instead of changing each and every single part on the player one by one. It's more efficient to use a For Loop to change them for you instead. Also, it is more convenient to just loop with a player:GetChildren()
and change for parts.
for _,v in pairs(player:GetChildren()) do if not v:IsA('Part') then return end -- Code end
But doing that means any part that gets grouped in the player will also be affected. Therefore, putting the names of the parts in a table is a fine method.
local CharParts = {"Right Arm", "Right Leg", "Left Arm", "Left Leg", "Head", "Torso"} for i = 1, #CharParts do -- Code end
More importantly, you need to define the part using :FindFirstChild()
and to change the parts' size below Vector3.new(1,1,1) , you got to change their FormFactor
to Custom
. Then you can change it to Vector3.new(.35,.35,.35) and above.
local Part = player.Character:FindFirstChild(CharParts[i]) Part.FormFactor = "Custom"
This is the final tested code:
local player = game.Players.LocalPlayer local CharParts = {"Right Arm", "Right Leg", "Left Arm", "Left Leg", "Head", "Torso"} for i = 1, #CharParts do local Part = player.Character:FindFirstChild(CharParts[i]) Part.FormFactor = "Custom" Part.Size = Vector3.new(0.4, 0.8, 0.4) end
There you go I think I explained every single part of the final code.