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

Efficient way to change player's BodyColor?

Asked by 5 years ago

At the moment I am doing this function to change the BodyColor of my player using an RGB value which is passed in a table. Is there a better way to do this without creating your own table and going through it?

Table Example:

{Reason = "ApplyBodyColor", BodyColor = Color3.fromRGB(255, 0, 0)}

Function Code:

function Edit.ApplyBodyColor(Player, BodyColor) -- Uses Color3.fromRGB()
    if (Player.Character ~= nil) then
        local Limbs = { -- BodyColor3 values
            "HeadColor3",
            "LeftArmColor3",
            "LeftLegColor3",
            "RightArmColor3",
            "RightLegColor3",
            "TorsoColor3"
        }
        for _, limb in ipairs(Limbs) do
            Player.Character["Body Colors"][limb] = BodyColor
        end
    end
end
0
you could loop for all parts in characters that name isnt HumanoidRootPart? ForgotenR4 68 — 5y
0
why are u using ipairs even User#23365 30 — 5y
0
Make a module for it The_Pr0fessor 595 — 5y
0
And loop through the parts The_Pr0fessor 595 — 5y

Answer this question