My frame is background Color not changing

You can write your topic however you want, but you need to answer these questions:

  1. I’m making game wher you can place pixels, pixels takes a clone of a frame.

  2. I use a module script for placing pixels and there is a value for color but doesn’t matter what’s the color it make it always black.

  3. I checked here and nothing worked i changed lines and it still doesn’t work

I use local script to use module script functions. I use mouse is “Button1Down” function.

local place = {}

function updatePixelColor(imageLabel, x, y, color)
	local imageRectSize = imageLabel.Size

	local u = x / (imageRectSize.X.Scale * imageLabel.AbsoluteSize.X)
	local v = y / (imageRectSize.Y.Scale * imageLabel.AbsoluteSize.Y)

	local pixelX = u * imageLabel.AbsoluteSize.X
	local pixelY = v * imageLabel.AbsoluteSize.Y

	local pixelFrame = game.ReplicatedStorage.Pixel:Clone()
	pixelFrame.Position = UDim2.new(0, pixelX, 0, pixelY)
	pixelFrame.BackgroundColor3 = color  
	pixelFrame.Parent = imageLabel
end

function place.onPixelPlaced(player, x, y, color)
	local canvasImage = player.PlayerGui.GUI.Pixels
	color = Color3.new(player.OnColor.Value)
	updatePixelColor(canvasImage, x, y, color)
end

return place
--This is for module script

local Player = game.Players.LocalPlayer
local UserInputService = game:GetService("UserInputService")
local Mouse = Player:GetMouse()
local PlayerGUI = Player.PlayerGui
local Place = require(script.Place)

Mouse.Button1Down:Connect(function(plr)
	local OnColor = Player:WaitForChild("OnColor")
	local x = Mouse.X - (1.2)
	local y = Mouse.Y + (35)
	Place.onPixelPlaced(Player, x, y)
	local frames = Player.PlayerGui.GUI.Pixels:GetChildren()
	print(Player.Name .." placed a pixel to ".."x:" .. x .. " y:" .. y .. " Color is:" .. OnColor.Value .. " Total pixels: " .. #frames)
end)

--And this is for the local script
1 Like
function place.onPixelPlaced(player, x, y, color)
	local canvasImage = player.PlayerGui.GUI.Pixels
	color = player.OnColor.Value
	updatePixelColor(canvasImage, x, y, color)
end
1 Like

I tried that it says color3 expected got string by the way the value that named “OnColor” is a string value and its value is “255, 0, 0”

Can you show us the on color in studio

then change it to a color3 value instead
or do

local array = (player.OnColor.Value):split(",")
color = Color3.new(tonumber(array[1]),tonumber(array[2]),tonumber(array[3]))

I used brickcolors instead of using color3 and it worked

I will try this hope that will work

so did it work or not i need an update lol

Brick color and color3 are kinda similar