I am trying to get the value of a textbox so I can input it into color3 and change the color of a brick
local brick = game.Workspace.Part
local red = game.StarterGui.ScreenGui.ColorPicker.R --these are the text boxes
local green = game.StarterGui.ScreenGui.ColorPicker.G
local blue = game.StarterGui.ScreenGui.ColorPicker.B
function Bread(Player)
local gamepassid = 11042304
local Player = game:GetService("Players").LocalPlayer
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId,gamepassid) then
brick.Color = Color3.fromRGB(red.Text,green.Text,blue.Text) print(red.Text,green.Text,blue.Text)
else
print("No gamepass detected... Prompting Purchase")
game:GetService("MarketplaceService"):PromptGamePassPurchase(Player,gamepassid)
end
end
script.Parent.MouseButton1Click:Connect(Bread)
local red = game.StarterGui.ScreenGui.ColorPicker.R
local green = game.StarterGui.ScreenGui.ColorPicker.G
local blue = game.StarterGui.ScreenGui.ColorPicker.B
into the function so that it can get the updated text, not the default text.
You need to get it from the player’s PlayerGui, not the StarterGui. You can just use the Text property to read the colors.
local player = game:GetService("Players").LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local brick = game.Workspace.Part
local red = playerGui.ScreenGui.ColorPicker.R
local green = playerGui.ScreenGui.ColorPicker.G
local blue = playerGui.ScreenGui.ColorPicker.B
function Bread(Player)
local gamepassid = 11042304
local Player = game:GetService("Players").LocalPlayer
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId,gamepassid) then
brick.Color = Color3.fromRGB(red.Text,green.Text,blue.Text)
print(red.Text,green.Text,blue.Text)
else
print("No gamepass detected... Prompting Purchase")
game:GetService("MarketplaceService"):PromptGamePassPurchase(Player,gamepassid)
end
end
script.Parent.MouseButton1Click:Connect(Bread)
In, “brick.Color = Color3.fromRGB(red.Text,green.Text,blue.Text)” You’re getting the string, try converting it to a number with tonumber()
Example:
local red = tonumber(game.StarterGui.ScreenGui.ColorPicker.R.Text)
local green = tonumber(game.StarterGui.ScreenGui.ColorPicker.G.Text)
local blue = tonumber(game.StarterGui.ScreenGui.ColorPicker.B.Text)
...
brick.Color = Color3.fromRGB(red,green,blue)