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

Color are not loading onto the brick when plr joins?

Asked by
Phixl 11
3 years ago
Edited 3 years ago

I'm having trouble setting it when a plr joins the game, a brick changes color based on his leaderstat brick value.

Please help

local
colors={
    [1] = "Terra Cotta", 

    [2] = "Black"
    }

-----------------------------------------------------   
game.Players.PlayerAdded:connect(function(player)
-----------------------------------------------------


local val = player:WaitForChild("Leaderstats").Brick.Value
local dd = workspace.Brick          

----------------------------------------------------------
if val >= 1 then
wait(1)
----------------------------------------------------------              
if val >= #colors then              
dd.BrickColor =  colors[#colors]
else
dd.BrickColor =  colors[val]                                    

        end
    end
end)

0
you forgot to add BrickColor.new(colors[#colors]) or BrickColor.new(colors[val]) AntoninFearless 622 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

Try this, it should work.

local
colors={
    [1] = "Terra Cotta", 

    [2] = "Black"
    }

-----------------------------------------------------   
game.Players.PlayerAdded:connect(function(player)
-----------------------------------------------------


local val = player:WaitForChild("Leaderstats").Brick.Value
local dd = workspace.Brick          

----------------------------------------------------------
if val >= 1 then
wait(1)
----------------------------------------------------------              
if val >= #colors then              
dd.BrickColor =  BrickColor.new(colors[#colors]) -- you need to do BrickColor.new() if you are working with brickcolors
else
dd.BrickColor = BrickColor.New(colors[val]) -- same here

        end
    end
end)

0
True. TheEagle722 170 — 3y
Ad

Answer this question