I'm trying to have a part light up when it has a certain value inside of it and when the mouse hovers over it, and then stop lighting up when the mouse stops hovering over it. While this is working there is a bug that occurs when I spam it between two parts with the value. It lights up one and when I move the mouse away it stays lit up. Here is the script:
--\\ Bools
local TargetPart = nil
local MouseDebounce = false
--// Inventory Module
local Inventory = {}
local InventoryGui = PlayerGui:WaitForChild'Inventory'
local Blur = InventoryGui:WaitForChild'Blur Background'
local Items = Blur:WaitForChild'Items'
MouseMove = function()
if MouseDebounce == false then
MouseDebounce = true
local Target = Mouse.Target
if Target ~= nil then
if Target:FindFirstChild'ItemID' then
if Client:DistanceFromCharacter(Target.Position) < 20 then
if Target:FindFirstChild'SelectionBox' == nil then
TargetPart = Target
local NewSelectionBox = SelectionBox:clone()
NewSelectionBox.Parent = Target
NewSelectionBox.Adornee = Target
end
end
elseif not Target:FindFirstChild'ItemID' and TargetPart ~= nil then
print ('True')
local Sb = TargetPart:FindFirstChild'SelectionBox'
if Sb then
Sb:destroy()
TargetPart = nil
end
end
end
MouseDebounce = false
end
end
Mouse.Move:connect(MouseMove)
