How to create a character Customization Menu (Part 1)

ive changed the code now it looks different

2 Likes

There are some things I’d like to mention out. If you won’t do anything with index, you can replace i with a _,. Since you are looping through an array since character:GetChildren() returns a table of everything which is inside the character, it’s much wiser to use ipairs.

Also it would be wise to check the data type of q since the script would error it wasn’t a BrickColor data type. You should also change q to something more readable which makes sense.

Here’s how a remastered version of your code would look like:

local character = plr.Character

for _, part in ipairs(char:GetChildren()) do -- Loop through every child of character
   if part:IsA("BasePart") and typeof(color) == "brickcolor" and part.BrickColor ~= color then -- check if its a basepart (meshpart, union, normal part etc ) 
       part.BrickColor = color -- change brick color
   end
end

Though checking if a brickcolor isn’t the same isn’t necessary but I’d like to have it since it’s my practice to not change something to x if it’s already x.

7 Likes

I was going to make that for a game, this is definitly going to help. Thanks! :slightly_smiling_face:

nope next part will come soon tho : )

Hmm, don’t know why you’re waiting for the character to load, since the script is firing from a remote, it’d better to check if the character even exists or not.

This is optional.

Can you explain more about this? If you’re talking about the speed, its almost negligible. The array returned by GetChildren() has all numerical indexes so it doesn’t make a difference to use ipairs or pairs.

I didn’t see if it was fired from a remote. It is always good practice to use ipairs over pairs when looping through an array. Ipairs will loop definitely while pairs will loop indefinitely.

" you can replace i with a _,"

Why put it if you don’t want to use it? That’s a bad practice. Same goes for not using self in a function that uses :.

2 Likes

In my game i`m using gui ( start customization and leveling changes) for changing Humanoid Description System - its works pretty good with colors.
Waiting for hair\accessories part - for now its works very unstable with my solution - sometimes i cant see actual changes on another player.

1 Like

I’ll be waiting for it :slightly_smiling_face:

1 Like

its coming tommrrow because i havent scripted the hair or any other parts yet lol

2 Likes

ill give a link to part 2 tommrrow

2 Likes

ok folks the part 2 is coming tommorrow

1 Like

There are much more effecient ways to do this. For example:

Local Script (Put in the same frame as all the color buttons)

local ColorChange = game.ReplicatedStorage:WaitForChild('ColorChange')
local buttonTable = script.Parent:GetChildren()

for index, button in pairs(buttonTable) do
    if button:IsA('Button') then
        button.MouseButton1Click:Connect(function()
            ColorChange:FireServer(button.BackgroundColor3)
        end
    end
end

Server Script

local ColorChange = game.ReplicatedStorage:WaitForChild('ColorChange')

ColorChange.OnServerEvent:Connect(player, color)
if player.Character then
    local character = player.Character

    for index, entity in pairs(character:GetChildren()) do
        if entity:IsA('BasePart') then
            entity.Color3 = color
        end
    end
end

I’m not 100% if entity.Color3 = color is correct, I wrote it off of memory and in like half a minute. That’s just an example how you can make it MUCH more effecient. Please dont show beginners ineffecient scripting practices. Its great how you are trying to contribute to the continue, but maybe you should begin by learning a little bit more and then trying to teach others about what you learnt. Have a great day! :slight_smile:

4 Likes

I do not even believe this is needed. You can take part of the event handler script and make it work solely from the button. Like this:

script.Parent.MouseButton1Click:Connect(function()
local plr = game.Players.LocalPlayer
local q = BrickColor.new("Pastel brown")

for i,v in pairs(char:GetChildren())do
    if v:IsA("Part")then
    v.BrickColor = q
   end
end
end)

I’m sorry about the indentation, I’m on mobile at the moment. This is more efficient, but it is more client-sided. If you would like to make it more protected against exploiters, you can do it the other way.

part 2 has been delayed @everyone

this tutorial is outdated and it sucks ill release a full version of this (remastered)

3 Likes

Isnt this the exact same thing as the youtube video:

I didnt really trust you so I searched it up and the first few minutes showed your same screenshot

4 Likes

my ui wasnt working so i had to borrow from this video

what happened was my studio was broken and it didnt let me make a gui i am working on a remastered version of this

Making inefficient stuff to beginners because a much efficient solution is “hard” for beginners, are not a good way to learn, if you want to achieve a decent result, you work hard on it, you get the thing that equals to the amount of what you’ve paid for (work, money, time, etc)

Anyway, you didn’t really mention about what is going on in each script, it’s like spoon-feeding, but not directly. Tutorials do not work like that. Tutorial is meant to tutor people how to do X, not to just put solution and leave it as that, they will never learn.

However, I am not here to argue, or targeting your posts, but this post quite disappointed me. But, since you are a beginner, which does make a bit sense why this tutorial is “low-quality”.

Alrighty, let’s get to the point, there a few things I want to say, the skin tone thing can be done by a for loop, which is by far probably the optimal and efficient solution, as you only have to have an array of colors and the system does the button creation, linking, etc for you, so you don’t have to copy and paste each button and connect it individually, which is quite painful, obviously.

Of course, a problem would be someone could’ve just abused that remote to set their skin tone to something else that isn’t included in the array, then, make the array a module and lock it (read only, with some fancy metatable tricks, though, might be performance intensive), and do the check in server, to check if the skin tone is in the array.

Hope you knew something new today :slight_smile:

2 Likes

well thank you for your reply, I know this is very bad and I apologize due to this I am making a new one with the points you said

1 Like