How do I make the outline color of the highlight to match the part color when a cursor is hovered over?

  1. What do you want to achieve? Match the outline of the highlight to be the same color as the part. it is from a module table and idk how a module table works

  2. What is the issue? right now its only hovered as grey (the default part color) and when hovered over a different color it remains grey

  3. What solutions have you tried so far? this issue isnt found on the dev hub and yt

local modtable = require(script.ModuleScript)
local part = modtable.ChooseRandom():Clone()

local hover = Instance.new("Highlight")
	local color = part.Color
	
	hover.OutlineColor = color
	hover.FillColor = Color3.fromRGB(0, 0, 0)
	hover.FillTransparency = 0.75
	hover.DepthMode = Enum.HighlightDepthMode.Occluded

         local function onHover()
		hover.Parent = part
	end
	
	local function onLeave()
		hover.Parent = nil
	end
1 Like

Could you send a screen recording or screen shot of the issue? I do not understand what not working.

1 Like

This is because, you create and set the highlight once.

local modtable = require(script.ModuleScript)
local part = modtable.ChooseRandom():Clone()
local hover = Instance.new("Highlight")
hover.FillColor = Color3.fromRGB(0, 0, 0)
hover.FillTransparency = 0.75
hover.DepthMode = Enum.HighlightDepthMode.Occluded

local function onHover()
    local color = part.Color
    hover.OutlineColor = color
    hover.Parent = part.Parent
end

local function onLeave()
    hover.Parent = nil
end

So the problem is that I put my color too early in the script?

You change the color only once, but parent it multiple times, the parent changes but the color never does.

local function onHover()
     hover.OutlineColor = part.Color
     hover.Parent = part
end

yep, it works perfectly. thanks a lot!

1 Like

you too man, i appreciate your help

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