so what should i do next to the game?
im still trying to figure out why it cant convert it to hex
Colors[tostring(colorpicked)]
did you say this comes out as nil?
well now it doesnt come out as anything
Mind sharing the full code?
(OH MY GOD I HATE 30 limit words)
sure,
game.Players.PlayerAdded:Connect(function(Player)
local partsFolder = workspace:WaitForChild("Parts")
local colorButtons = Player.PlayerGui:WaitForChild("ScreenGui").Frame
Colors = { ["Red"] = "#FF0000", ["Yellow"] = "#FFE600", ["Green"] = "#45DB00", ["Light Blue"] = "#00FFE1", ["Blue"] = "#008CFF", ["Pink"] = "#FF00FF", ["Purple"] = "#BF00FF", ["White"] = "#FFFFFF", ["Black"] = "#000000" }
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = Player
local Color = Instance.new("StringValue")
Color.Parent = leaderstats
Color.Name = "Color"
local function changePartColor(part, colorpicked)
print("Changing color of part:", part.Name, "to color:", colorpicked)
part.Color = Color3.fromHex(Colors[tostring(colorpicked)])
print("New color of part:", part.Name, "is:", part.Color)
end
for i, Button in pairs(colorButtons:GetChildren()) do
if Button:IsA("TextButton") then
Button.MouseButton1Click:Connect(function()
Player.leaderstats.Color.Value = Button.Name
end)
end
end
for _, part in ipairs(partsFolder:GetChildren()) do
if part:IsA("BasePart") then
local clickDetector = Instance.new("ClickDetector")
clickDetector.Parent = part
clickDetector.MouseClick:Connect(function()
changePartColor(part, Player.leaderstats.Color.Value)
end)
end
end
end)
print(Colors[tostring(colorpicked)])
i meant
\\\\\
yeah it doesnt come out as anything
yeah it doesnt come out as anything
print(Color3.fromHex(Colors["Red"]))
what does this output for you
what line should i replace to this code?
Colors = { ["Red"] = "#FF0000", ["Yellow"] = "#FFE600", ["Green"] = "#45DB00", ["Light Blue"] = "#00FFE1", ["Blue"] = "#008CFF", ["Pink"] = "#FF00FF", ["Purple"] = "#BF00FF", ["White"] = "#FFFFFF", ["Black"] = "#000000" }
under this one
that print “1, 0, 0” so its right
ok so its working, im pretty sure theres something wrong with our variable colorpicked
. replace this with the one below and tell me what gets outputted.
local function changePartColor(part, colorpicked)
print(colorpicked)
part.Color = Color3.new(Colors[tostring(colorpicked)])
end
ok, when i click a part with black selected, it outputs “Really Black” and when i click it with yellow selected, it says “New Yeller” (i named the buttons that way)
i think you might have messed it up by changing the names of the buttons.i used color names to assign hex values and the buttons names arent the same as the names i assigned to the hex values in the dictionary colors
oh, ill change the names of the buttons then
you have to change each name in Colors
to the names you gave the buttons
im just gonna change the name of the buttons
\\\\\\\\\\\\\\\\\\\