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

How would I make this change brick colors? I have yet to figure it out.

Asked by 5 years ago
Edited 5 years ago

I have this script that if you have a value, you should get a new hair color on a reset or join, but it doesn't work? Line 24 is the issue although there is no output error, I am almost positive it is, any help, heres the script

local bucnhOfColor = {
    [1] = "Black", --Default Shirt
    [2] = "Pine Cone", -- Army green
    [3] = "rbxassetid://2397305859", --Guess reckless
    [4] = "rbxassetid://885261392", --Hawaiian shirt
    [5] = "rbxassetid://3144003341", --JackMercando shirt
    [6] = "rbxassetid://3152639503", -- Osito Pink Shirt
    [7] = "rbxassetid://668772580", -- Red Jacket
    [8] = "rbxassetid://554084413", -- Supreme Worldflags
    [9] = "rbxassetid://2970602368", -- Tank top
    [10] = "rbxassetid://2072675468", -- Tommy hilfiger
    [11] = "rbxassetid://2641146107", -- Tour Jacket
    [12] = "rbxassetid://604130756", -- Yellow puffer
    [13] = "rbxassetid://393696145", -- Yellow puffer
}

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:Connect(function(character)       
        local d = character:WaitForChild("Hat")
        local val = player:WaitForChild("leaderstats").HairColor.Value
        if val >= 1 then
            wait(1)
            if val >= #bucnhOfColor then
                d.Handle.BrickColor = BrickColor.new(b ucnhOfColor[#bucnhOfColor])
            else
                d.Handle.BrickColor =  bucnhOfColor[val]
            end
        end
    end)
end)
0
use `BrickColor.new()` not `BrickColor.new[]` EteraW 77 — 5y
0
Use the brackets when referring to the item in the table AltNature 169 — 5y
0
brickcolor.new is a function, therefore it should have a `:()` beside it not a `:[]` AltNature 169 — 5y
0
Its still not working even with the () Pooglies 7 — 5y
View all comments (2 more)
0
Are the asset IDs written from the third key of the dictionary named "bunchOfColors" supposed to exist? And did it work when you obtain your first point? Afterl1ght 321 — 5y
0
So I had a shirt giver script, and now im trying to make a hair giver, so that is just leftover code until I get this fixed. Pooglies 7 — 5y

1 answer

Log in to vote
2
Answered by 5 years ago
Edited 5 years ago

You seem to like using the method I showed you, haha

That's at least what I thought of like when I ad-lib.

REASON

Have you read the output? When you assign a value to a BrickColor property, the new value should be a BrickColor datatype, did you notice? It appears that you're trying to apply a String (text) value to the Handle's BrickColor at line 26.

That being said, the new value should be BrickColor.new(bucnhOfColor[val]) instead.

Now, to prevent further... unwanted events from occurring, you should not include those asset IDs for shirts in that script anymore. Also, I now doubt that you're trying your best to fix the issue on your own, so if you aren't, you should try harder before asking us! :)

Also, if the Handle of the accessory has a Mesh and a texture, the texture (with little to no transparency) may override the Handle's color. You should remove its texture if it has one, or just keep it if you think the texture synchronizes with the color of the Part.

time to fix stuff

As regards what I first mentioned above, here is an abbreviated illustration on how to fix it.

--yea it's simple
--Your script from line 23
if val >= #bucnhOfColor then
    d.Handle.BrickColor = BrickColor.new(bucnhOfColor[#bucnhOfColor]) --this is correct
else
    d.Handle.BrickColor =  BrickColor.new(bucnhOfColor[val]) --this line was wrong, now it should be fixed.
end

Simple as that!

Tell me if you have more issues arriving after. Cheers!

0
Thank you so much ;)It worked perfectly. Pooglies 7 — 5y
0
Haha, no probs, although that's just an insignificant mistake. You should've checked in the Output, and I'm sure the error was printed there. I don't believe you haven't had such an ability of debugging, so you might want to try fixing the scripts by yourselves, if you could? c: Afterl1ght 321 — 5y
Ad

Answer this question