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

BackgroundColor3 is not changing?

This is the part of the script I'm having trouble with. Variables R, G, and B take player input.

local R
local G
local B
local RGB = R..","..G..","..B

print(RGB)
local P = Instance.new('Frame')
P.Name = 'MenuBackground'..PWidth..PHeight
P.Size = UDim2.new(0,1,0,1)
P.Position = UDim2.new(0,PWidth,0,PHeight)
repeat wait()
	P.BackgroundColor3 = Color3.fromRGB(tonumber(RGB))
until P.BackgroundColor3 == Color3.fromRGB(tonumber(RGB))
print(P.BackgroundColor3)
P.Parent = Surface
P.BorderSizePixel = 0

If you've noticed, I put print before and after it applies the Color3.fromRGB. Output verifies that RGB is not a blank value and it DOES give out a complete string - ex. 168,255,131 - however the script doesn't seem to apply the RGB Value even if I've set it to repeat the task until it actually holds the Color3 value. Despite this, the second print output always says 0,0,0 and the GUI's background is always just black. I've been trying to solve this problem for three days and I'm at wits end. Is this an error on ROBLOX/Studio's side?

2 comments

0

Upon inputing this script, I was given this "attempt to concatenate local 'B' (a nil value)"

0

You need to declare what "R, "G", "B" are. So local R = "R", local G = "G", local B = "B", that's the first issue, now you need to declare what PWidth, and PHeight are.

2 answers

Declare what each local letter is, just like below.

local R = "R"
local G = "G"
local B = "B"
local RGB = R..","..G..","..B

print(RGB)
local P = Instance.new('Frame', WhereYouWantTheFrame)
P.Name = 'MenuBackground'..PWidth..PHeight --[[ I don't know if you've declared what PWidth, and PHeight are, but if not, you need to declare what those are --]]
P.Size = UDim2.new(0,1,0,1)
P.Position = UDim2.new(0,PWidth,0,PHeight)
repeat wait()
    P.BackgroundColor3 = Color3.fromRGB(tonumber(RGB))
until P.BackgroundColor3 == Color3.fromRGB(tonumber(RGB))
print(P.BackgroundColor3)
P.Parent = Surface
P.BorderSizePixel = 0

3 comments

0

I do declare R,B, and G. Their values are inputted through a GUI TextBox and I can guarantee that they are not blank since the first print() outputs the numbers that I entered

0

Ah alright, now that I'm looking at it, have you told the script where to input the new instance? You did local P = Instance.new('Frame') but I think you need to tell it where to put the frame.Local p = Instance.new('Frame', WhereYouWantToCreateTheFrame) I'm a bit newer to scripting than most people; so I'm trying my best.

0

The Frame is parented to a brick called Surface as seen on line 15

To make it simpler, I did a small test and made a blank place with only the baseplate in it. I put a SurfaceGui in the baseplate, and a Frame in the SurfaceGui. The new Frame's BackgroundColor3 is white before I apply the following script:

local SampleString = "155,212,0"

script.Parent.SurfaceGui.Frame.BackgroundColor3 = Color3.fromRGB(tonumber(SampleString))

However, instead of changing the frame's BackgroundColor3 to an actual Color, it changes to black... The same happens even without tonumber()

script.Parent.SurfaceGui.Frame.BackgroundColor3 = Color3.fromRGB(SampleString)

You could try this experiment for yourself with the above conditions and code I've supplied. I'm starting to suspect this might be an error in Studio.

5 comments

0

P.S. There is no error in the output. The script behaves as if it actually set BackgroundColor3 to the above value.

0

I think it is a ROBLOX error, it should be working.

0

Did you try the experiment out? This issue is incredibly frustrating! For anyone else curious, try the experiment above.

0

What color is the SampleString supposed to be?

0

It's supposed to be Yellow-Green

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