Why isn't the Part changing colors when I click on a color?

Hi so i don’t know why the Part isn’t changing the colors when I click on a color.

Any ideas on how to fix this? I am using a string value to send it to the server,but Remote Event and
the String Value doesn’t really work.

So, if I print it, it will display the color name, but on the server side, it doesn’t print anything and shows ‘nil’.

Here is the Local Script:

local ColorFrame = script.Parent
local ColorValue = game.ReplicatedStorage:FindFirstChild("ColorName")


for i, buttons in pairs(ColorFrame:GetChildren()) do
	if buttons:IsA("TextButton") then
		local ColorName = buttons.Name
		if ColorName then
			buttons.MouseButton1Click:Connect(function()
				ColorValue.Value = ColorName
				print(ColorValue.Value)
		
			end)
		end
	end
end

Server Script:

local ColorName = ReplicatedStorage:FindFirstChild("ColorName")
local block = game.Workspace

	block.BrickColor = BrickColor.new(ColorName.Value)

Apologies for my scripting skills; they aren’t great. Any Help would be greatly appreciated. Thank you!

1 Like

Its not changing because you are only changing the value on the Client Side. You have to use a RemoteEvent to send the Client information to the server.

local ColorFrame = script.Parent
local RemoteEvent = game.ReplicatedStorage.RemoteEvent

for i, buttons in pairs(ColorFrame:GetChildren()) do
	if buttons:IsA("TextButton") then
		local ColorName = buttons.Name
		if ColorName then
			buttons.MouseButton1Click:Connect(function()
				RemoteEvent:FireServer(ColorName)
			end)
		end
	end
end
local block = game.Workspace
local RemoteEvent = game.ReplicatedStorage.RemoteEvent

RemoteEvent.OnServerEvent:Connect(function(plr, ColorName)
     block.BrickColor = BrickColor.new(ColorName)
end)

You may have to change what exactly you are sending, but if the button’s name is Dark Blue or one of the default roblox BrickColors, it should work fine.

local block = game.Workspace

Aren’t you just making a variable that includes the entire game?

local block = game.Workspace.(Whatever model or folder the block is in).Part

The issues is that I am also doing a placement system as well because I want players to be able to change the color while placing blocks. However, when I use two remote events in the same script, it spawns 5 blocks instead of 1 when I click. That’s why i used a string value …

But tysm for it

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.