How do I create a Color Settings GUI?

How do I fix this script? I’m trying to make it so when you enter the colour code into a GUI and click the button it will change the colour.

Current code:

local color = game.StarterGui.ScreenGui.SettingsFrame.TextBox.Text

local frame = game.StarterGui.ScreenGui.Click

local frame2 = game.StarterGui.ScreenGui.SettingsFrame

local frame3 = game.StarterGui.ScreenGui.Main

local frame4 = game.StarterGui.ScreenGui.Settings

script.Parent.MouseButton1Click:Connect(function()

frame.BackgroundColor3 = Color3.fromRGB(color)

end)

I know I most likely made a stupid mistake but i’m just not sure how to fix it.

Okay so to get the color code you have to first seperate the text in the color textbox

The way you do that is by using string.split

local segments = string.split(color, ",")

then you have to convert the segments from string to number and put them in to the color3.fromrgb

Color3.fromRGB(tonumber(segments[1]),tonumber(segments[2]),tonumber(segments[3]))

And also just so you know

the input has to be in this format r,g,b

Sadly that does not work… I’ve tried looking in output for errors but nothing so i’m very confused.

local color = game.StarterGui.ScreenGui.SettingsFrame.TextBox.Text

local frame = game.StarterGui.ScreenGui.Click

local frame2 = game.StarterGui.ScreenGui.SettingsFrame

local frame3 = game.StarterGui.ScreenGui.Main

local frame4 = game.StarterGui.ScreenGui.Settings

local segments = string.split(color, “,”)

script.Parent.MouseButton1Click:Connect(function()

frame.BackgroundColor3 = Color3.fromRGB(tonumber(segments[1]),tonumber(segments[2]),tonumber(segments[3]))

end)

Correct me if I’m wrong, but…

You shouldn’t be using game.StarterGui. Instead, make a variable for the LocalPlayer and get their PlayerGui.

local player = game.Players.LocalPlayer

player:WaitForChild("PlayerGui") -- replace game.StarterGui with this line
2 Likes

Try this (With the fix that decodedMint talked about)

local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
local color = PlayerGui .ScreenGui.SettingsFrame.TextBox

local frame = PlayerGui.ScreenGui.Click

local frame2 = PlayerGui.ScreenGui.SettingsFrame

local frame3 = PlayerGui.ScreenGui.Main

local frame4 = PlayerGui.ScreenGui.Settings

script.Parent.MouseButton1Click:Connect(function()

local segments = string.split(color.Text, “,”)

frame.BackgroundColor3 = Color3.fromRGB(tonumber(segments[1]),tonumber(segments[2]),tonumber(segments[3]))

end)
1 Like

O, thank you for spotting that. I didn’t see it.

Good job :smile:

1 Like

17:10:50.901 - Players.tyler09456.PlayerGui.ScreenGui.SettingsFrame.TextButton.LocalScript:13: Unexpected Unicode character: U+201c. Did you mean ‘"’?

Ok, i’ll do that now! Thanks for telling me.

1 Like

I’ve still got that error even when trying @DecodedMint’s fix

** 17:15:56.533 - Players.tyler09456.PlayerGui.ScreenGui.SettingsFrame.TextButton.LocalScript:15: Unexpected Unicode character: U+201c. Did you mean ‘"’?**

Looks like DevForum converted one of the characters in the script

make sure that is sais " instead of “

Its really hard to spot, but there is a difference

Yeah i’ve fixed that.

I’ve now got an issue where it can only be black and it does not matter what you put into it.

Try to print out what it sets the color3 to

so do this

local NewColor3 = Color3.fromRGB(tonumber(segments[1]),tonumber(segments[2]),tonumber(segments[3]))
print(NewColor3)
frame.BackgroundColor3 = NewColor3

What does it print out?

I’ve done that and here is the result:
**

**

What did you input in to the text box?

It does not matter what I put in, it always only fills the first part of the color code and leaves the other two , 's with 0 which most likely causes this.

Can i jump in to studio with you?

because i have no idea what is happening

Sure, add me on Roblox and i’ll get you on the studio.

You now have perms to edit, heres the game link: Place :) - Roblox

script.parent.MouseButton1Clicked:Connect(function()
script.Parent.Color = Color3.fromRGB("Really Red")
(end)

Just make manual buttons, like Arsenal. Click the button, opens a frame up, then whatever thing you click, it clicks. It will always override the last color change.
Gooday!
Edit: It can be any color you’d like, just handpicked a example.