Randomized StarterCharacter

I would like to make script that randomizes character torso colors and leg colors, but I’ve tried to make a script with help from the Dev Forum in the past and I havent been able to. How would I do this?

1 Like
-- Your character
local Character = Player.Character
-- Table of every instance inside your character
local CharacterChildren = Character:GetChildren()

-- Iterate through table
for i,v in ipairs(CharacterChildren) do
	
	-- Checks if v is a bodypart
	if v:IsA("BasePart") then

		v.Color = Color3.new(math.random(),math.random(),math.random())

	end

end

Would this go in ServerScripts, StarterPlayer or StarterCharacter?

Either StarterCharacter or ServerScripts. I recommend doing it on StarterCharacter if you want the player to get a random color when they respawn.

Maybe don’t use chatgpt

local Character = game:GetService("Players").LocalPlayer.Character

if Character then
    local Humanoid = Character:FindFirstChildWhichIsA("Humanoid")

    local function randomizeobj(BasePart : BasePart)
        if BasePart then
            BasePart.BrickColor = BrickColor.random()
        end
    end

    if Humanoid then
        randomizeobj(Humanoid.LeftLeg)
        randomizeobj(Humanoid.RightLeg)
    end
    randomizeobj(Character:FindFirstChild("Torso"))
end

I got the error “Character is not a valid member of ‘Players’”

if the script is inside StarterCharacter then the Character is script.parent

local Character = Player.Character --instead of this

local Character = script.Parent -- Do this

already fixed it I forgot to add “.LocalPlayer”

? What is that supposed to mean?

I’m saying you’re using chatgpt

first off your comments
second off you’re iteration is calling a table value

1 Like

I’m not using chatgpt buddy, it’s rude to go around saying that for no good reason

my apologizes it was not my intent to be rude.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.