Paint tool not working

My paint tool is supposed to select the color from a StringValue in the LocalPlayers GUI named Colorv and paint the mouse.Target the StringValue.Value

Error:

Code:

tool.Activated:Connect(function()
	if game.Players.LocalPlayer.Settings.CanBuild.Value == true then
	local t = Mouse.Target
	for _,blocks in pairs(workspace.Paintable:GetChildren()) do
		if t == blocks then
				local color = BrickColor.new[game.Players.LocalPlayer.PlayerGui.ColorPallete.Colorv.value]
			Remotes.Paint:FireServer(t, color)
				end
		end
	end
end)

image

What the value looks like: image

It should’ve been obvious enough from the error messages.
ScreenShot_20210615181557
Those are brackets, not parentheses. BrickColor.new is a function, and by using brackets you are trying to index the function.

1 Like

I tried that, the block im trying to paint turns black and not the specified color

I’m pretty sure capitalization matters. Go back and check the spelling.
image


https://gyazo.com/4b86324bb38120049ad6af91c0a76859

Client:

tool.Activated:Connect(function()
	if game.Players.LocalPlayer.Settings.CanBuild.Value == true then
	local t = Mouse.Target
	for _,blocks in pairs(workspace.Paintable:GetChildren()) do
		if t == blocks then
				local color = Color3.new(game.Players.LocalPlayer.PlayerGui.ColorPallete.Colorv.value)
			Remotes.Paint:FireServer(t, color)
				end
		end
	end
end)

Server:

Remotes.Paint.OnServerEvent:connect(function(player, part, color)
	if player.Settings.CanBuild.Value == true then
		if part.Paintable.Value == true then
		if player.Settings.Banned.Value == false then
				part.Color = Color3.new(color)
				part.Holder.Value = player.Name
				part.Paintable.Value = false
			end
		end
	else
		print("You can't build")
	end
end)

Checked your code, turns out you’re trying to create another Color3 value WITH the BrickColor. You should’ve just directly set the part’s color to the brickcolor.

Example from the API reference
image

1 Like

Ohhh okay so I should do part.BrickColor = BrickColor.new(color)

The BrickColor value was already generated on the client before it got sent through the remote. It should be part.BrickColor = color

(I’m referring to the original script)

1 Like


Found the error I got it to work.

1 Like