Highlight System

Hello,
I am trying to make system that adds Highlights to every part in workspace.
I wanted to achieve highlight color to be part color but little darker, but i got this error:

ServerScriptService.Script:13: attempt to index number with 'Color'

Script:

local parts = game.Workspace:GetDescendants()

for _, v in pairs(parts) do
	if v:IsA("BasePart") then
		local r1 = v.Color.R
		local g1 = v.Color.G
		local b1 = v.Color.B
		
		function x(n1, n2)
			return n1 - n2
		end
		
		local r = x(r1.Color.R, 50)
		local g = x(g1.Color.G, 50)
		local b = x(b1.Color.B, 50)
		
		local line = Instance.new("Highlight")
		line.FillTransparency = 1
		line.DepthMode = Enum.HighlightDepthMode.Occluded
		line.OutlineTransparency = .6
		line.OutlineColor = Color3.new(r, g, b)
		line.Parent = v
	end
end

If is this even possible to achieve something like this?

1 Like

You shouldn’t be doing r1.Color.R since you are doing it already when setting the variable.

Try setting it to this:

		local r = x(r1, 50)
		local g = x(g1, 50)
		local b = x(b1, 50)
1 Like

Highlight only have black color

*Edit in properties color is correct but in game something is odd
idk I am dumb it isnt correct

You should try doing this:

function color3torgb(color3, decreaseamount)
	return color3.R*255 - decreaseamount,color3.G*255 - decreaseamount,color3.B*255 - decreaseamount
end

line.OutlineColor = Color3.fromRGB(color3torgb(Color3.new(v.Color.R, v.Color.G, v.Color.B), 30))
-- // The 30 is the decrease amount, so how much you want to decrease the color by

Full code:

local parts = game.Workspace:GetDescendants()

function color3torgb(color3, decreaseamount)
	return color3.R*255 - decreaseamount,color3.G*255 - decreaseamount,color3.B*255 - decreaseamount
end

for _, v in pairs(parts) do
	if v:IsA("BasePart") then
		local line = Instance.new("Highlight")
		line.FillTransparency = 1
		line.DepthMode = Enum.HighlightDepthMode.Occluded
		line.OutlineTransparency = .6
		line.OutlineColor = Color3.fromRGB(color3torgb(Color3.new(v.Color.R, v.Color.G, v.Color.B), 30))
		line.Parent = v
	end
end

If you’re trying to use highlights to create a cell shading effect, that would probably not be the best way to go about it. Workspace only allows up to 31 active highlight objects for performance reasons. The best way to go about this is to use inverted meshes. If you’re using just parts, all you have to do is go into blender, hit scale -1 on the basic cube, export from blender, import into roblox, and make sure double sided is off.

1 Like

The color is working right now but something went wrong with highlights

I am trying to achieve something like old smooth surface with outlines

Something like this:

obraz

Yeah, you should be able to use inverted parts to do that, or you can find old roblox parts in the toolbox that still have the surface properties and just use those.

I am pretty sure that even if you get an old part with any surface that has outlines, it still wont have outlines.

when u access to surface property u would see SmoothNoOutlines is not default surface the default one is smooth

I think it was just old roblox thing or something like this

maybe this :

local parts = workspace:GetDescendants() -- wokspace instead of game.Workspace for more optimized code

for _, v in ipairs(parts) do
if v:IsA("BasePart") then
local r1 = v.Color.R
local g1 = v.Color.G
local b1 = v.Color.B
local d = 50

local function x(n1, n2)
return n1 - n2
end

local r = x(r1,  d)
local g = x(g1, d)
local b = x(b1, d)

local line = Instance.new("Highlight", v) -- Parent it immedietely
line.FillTransparency = 1
line.DepthMode = Enum.HighlightDepthMode.Occluded
line.Outline.Transparency = 0.6
line.OutlineColor = Color3.fromRGB(r, g, b)

end
end

will that work?

You can get around the 31 max by just putting a highlight object in a model object and putting all the parts you want highlighted inside :stuck_out_tongue: kinda weird but it works.