I’m trying to make a simple highlight hover when your mouse hovers over the npc, however if you do it really fast it starts glitching out, so I want to know if theres a way to make it much smoother.
Show us your code so we can help…
Probably adding a debounce could fix the problem. Make it so that when the mouse enters, it will wait for the highlight to finish playing, and then check if the mouse exited, and if so, then play the thing for the mouse exit. Of course, vice versa would also apply for the mouse exiting.
1 Like
for i,ClickDetector in pairs(game.Workspace.NPCS:GetDescendants()) do
if ClickDetector:IsA("ClickDetector") then
ClickDetector.MouseHoverEnter:Connect(function()
game:GetService("RunService").Heartbeat:Wait()
create("Hovering", 0.3, Player.Character)
hightlight:Clone()
hightlight.Parent = ClickDetector.Parent.Parent.Parent
hightlight.Enabled = true
TweenService:Create(hightlight, TweenInfo.new(.15, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut), {
FillTransparency = 0.75,
OutlineTransparency = 0.7
}):Play()
end)
ClickDetector.MouseHoverLeave:Connect(function()
game:GetService("RunService").Heartbeat:Wait()
TweenService:Create(hightlight, TweenInfo.new(.15, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut), {
FillTransparency = 1,
OutlineTransparency = 1
}):Play()
wait(.15)
hightlight.Parent = nil
return Player
end)
end
end
2 Likes
local Tween = TweenService:Create(hightlight, TweenInfo.new(.15, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut), {
FillTransparency = 0.75,
OutlineTransparency = 0.7
})
tween:Play()
tween.Completed:Connect(function()
--mouse leaving part...
end
Cancel the tween once the client’s mouse stops hovering over the NPC, you are currently stacking tweens.
hightlight:Clone()
hightlight.Parent = ClickDetector.Parent.Parent.Parent
hightlight.Enabled = true
You’re also cloning something named ‘highlight’ but not doing anything with the clone.
local clone = object:Clone()
--Reference 'clone' to manipulate the clone.