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

Works for the meshparts and parts, but for unions it just fails. Anybody?

Asked by
5qfb -8
4 years ago
Edited by JesseSong 4 years ago

Please encode Lua code in the Lua block code tag (look for the Lua icon in the editor).
local ColorTable = {
    Color3.fromRGB(196, 40, 28),--Red
    Color3.fromRGB(0, 16, 176),--Dark Blue
    Color3.fromRGB(40, 127, 71),--Dark Green
    Color3.fromRGB(255, 102, 204),--Pink
    Color3.fromRGB(218, 133, 65),--Orange
    Color3.fromRGB(245, 205, 48),--Yellow
    Color3.fromRGB(27, 42, 53),--Black
    Color3.fromRGB(242, 243, 243), --White
    Color3.fromRGB(140, 91, 159),--Purple
    Color3.fromRGB(124, 92, 70),--Brown
    Color3.fromRGB(18, 238, 212),--Teal
    Color3.fromRGB(0, 255, 0),--Lime
}




game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)

        local Parts = char:GetChildren()
        local RandomColor = ColorTable[math.random(1,#ColorTable)]
        for i = 1,#Parts do
            if Parts[i].ClassName == "MeshPart" or Parts[i].ClassName == "Part" or Parts[i].ClassName == "Union" then
                Parts[i].Color = RandomColor                
            end
        end
    end)
end)
0
im new to here so ignore the format 5qfb -8 — 4y
0
"--" acts as a comment on each line, so ignoring the lack of formatting on this post, your table only includes 5 colors excluding the line that starts with "Blue" because that is invalid.. SteamG00B 1633 — 4y
0
And the first answer given should work, so to make sure you've got it ticked on all unions, you should just set that property before you change the color to be sure. SteamG00B 1633 — 4y

3 answers

Log in to vote
0
Answered by
sleazel 1287 Moderation Voter
4 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.

Actually it's:

Parts[i].ClassName == "UnionOperation"

for some reason. Also yes, you need to tick UsePartColor. Just to let you know, if your unions are multi-coloured, it will mess them up.

Ad
Log in to vote
-1
Answered by 4 years ago

When answering, if your answer does not fully solve the question, it should be written as a comment to the question instead of as an answer.

On the union, tick the use part color option. See if that works.

0
sorry but it doesnt work 5qfb -8 — 4y
Log in to vote
-1
Answered by 4 years ago
Edited 4 years ago

When answering, if your answer does not fully solve the question, it should be written as a comment to the question instead of as an answer.

I'm guessing you're trying to randomly change the color of the unions? If there's no errors and it's not changing color this is probably because unions colors can't be changed unless you tick off a specific property in the union. To do this, go into the properties of the unions and tick off usepartcolor (I believe that's the one) and it should work.

0
still doesnt work 5qfb -8 — 4y

Answer this question