Hello, I am making a grid for a game. I want parts that my mouse hovers over to change color and then revert to the color it was previously when the mouse leaves the part.
However, I am unsure how to do this because I don’t want the script to revert the color of the part if the mouse is still hovering over it.
The Script:
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local TS = game:GetService("TweenService")
local CS = game:GetService("CollectionService")
print("THIS IS RUNNING")
mouse.Move:Connect(function()
if CS:HasTag(mouse.Target,"Highlightable") then
local T = mouse.Target
local bc = T.BrickColor
local tweenInfo = TweenInfo.new(0.1, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut, 0, false, 0)
local tweenIn1 = TS:Create(mouse.Target,tweenInfo,{Color = Color3.fromRGB(175, 255, 70)})
print(mouse.Target)
tweenIn1:Play()
end
end)
How it runs as of now:
I am also aware that MouseHoverEnter and MouseHoverLeave exist, but I am not sure if implementing them will be a good idea because I plan on having many of these parts in my game.