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

How do I make a part's color become the color of a backgroundcolor3 in a textbutton?

So basically i am trying to make this GUI where you can insert parts, change its color and position. But I keep getting this error that says, "Color is not a valid member of textbutton." Anyways here are my 2 scripts

-- local script

local buildingGUI = script.Parent
local BuildingFrame = buildingGUI:WaitForChild("BuildingFrame")

local CreatePartButton = BuildingFrame.CreatePartButton
local ColoringFrame = buildingGUI.ColoringFrame

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local BuildObjects = ReplicatedStorage:WaitForChild("BuildObjects")

local canMovePart = false

local part = BuildObjects.Part

local mouse = game:GetService("Players").LocalPlayer:GetMouse()

local BuildEvent = ReplicatedStorage.RemoteEvents.BuildEvent


CreatePartButton.MouseButton1Click:Connect(function()
local clonedPart = part:Clone()
	clonedPart.Parent = game.Workspace
	clonedPart.Transparency = 0.7
	clonedPart.Position = mouse.Hit.p
	
	ColoringFrame.Visible = true
	
	for i, v in pairs(ColoringFrame:GetChildren()) do
		if v:IsA("TextButton") then
			v.MouseButton1Click:Connect(function()
				local selectedColor = v
				local backGroundColor = v.BackgroundColor3
				clonedPart.Parent = game.Workspace
				clonedPart.Position = mouse.Hit.p
				mouse.Move:Connect(function()
					if canMovePart == false then
						
					clonedPart.Position = mouse.Hit.p
						mouse.Button1Down:Connect(function()
							local finalPartPosition = mouse.Hit.p
							BuildEvent:FireServer(backGroundColor,selectedColor,clonedPart,finalPartPosition)
							canMovePart = false
						end)
						end
				end)
				end)
			end
		end
			
	end)
-- server script


local ReplicatedStorage = game:GetService("ReplicatedStorage")

local RemoteEvents = ReplicatedStorage.RemoteEvents
local buildEvent = RemoteEvents:WaitForChild("BuildEvent")

buildEvent.OnServerEvent:Connect(function(backGroundColor,selectedColor,clonedPart,finalPartPosition)
	clonedPart.Color = Color3.new(backGroundColor)
	clonedPart.Position = finalPartPosition
	clonedPart.Transparency = 0
	
	clonedPart.Parent = game.Workspace
end)


2 comments

0

the error appears in the script or local script?

0

the script

1 answer

The error means that your clonedPart is a TextButton, and you tried to set TextButton.Color on line 10 of the server script, but the object does not have this property. Probably you want to change BackgroundColor or TextColor

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