Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Color are not loading onto the brick when plr joins?

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)

1 comment

0

you forgot to add BrickColor.new(colors[#colors]) or BrickColor.new(colors[val])

1 answer

✓ Accepted answer

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)

1 comment

0

True.

This discussion is preserved as it was. New answers, comments, and votes are closed.