Chaning Colour in a GUI via script doesn;t work

Im trying to change the colour of a frame created in an Instance.new, but when I try to change the frame backgroundcolour3 it wont work, what could be wrong?

local Players = game:GetService("Players")
local players = Players.LocalPlayer
local SG = Instance.new("ScreenGui")
local Initiate = Instance.new("TextLabel")

local OpenButton = Instance.new("Frame")
local OpenText = Instance.new("TextButton")

--Important Stuff
SG.Parent = game.StarterGui
Initiate.Parent = SG
OpenButton.Parent = SG
OpenText.Parent = OpenButton



--OpenButton
OpenButton.Size = UDim2.new(0, 100,0, 46)
OpenButton.Position = UDim2.new(0.467, 0,0.928, 0)
OpenButton.BackgroundColor3 = Color3.new(129, 129, 129) --Here is issue but idk why :think:
OpenButton.BorderColor3 = Color3.new(255, 255, 255)
OpenButton.BorderSizePixel = 5

OpenText.Size = UDim2.new(0, 100,0, 50)
OpenText.Position = UDim2.new(0, 0,0, 0)
OpenText.BackgroundTransparency = 1
OpenText.Font = Enum.Font.GothamBlack
OpenText.TextSize = 14
OpenText.TextColor3 = Color3.new(255, 255, 255)

On this line of code, OpenButton.BackgroundColor3 = Color3.new(129, 129, 129) --Here is issue but idk why :think: the OpenButton is meant to change colours, but when I go into studio everything works well except that. What could be the reason?

1 Like

Everything looks fine to me (though I did not properly go through the code), it might be because of the properties you’ve set for the frame, possible the background is transparent or something else.

You should be parenting to Player.PlayerGui not to StarterGui. Also you are mixing the Color3.new constructor with Color3.fromRGB. The latter takes input from 0-255 whereas the former takes input from 0-1.

2 Likes

But how come it has worked with the rest of the script and not that one specifically. Also when I set it to PlayerGui, I get an error upon testing the game.

1 Like

I do not know, but if you apply the changes I have recommended it should work

1 Like

Why are you even creating this with a script? You can just make it in editing mode.

Edit: Nvm

Just because I am terribly bored and have nothing better to do and I am also testing a few I thought about

Maybe because he could be practicing scripting and just testing things out?

2 Likes