Tween service highlight

You can write your topic however you want, but you need to answer these questions:

  1. I would like too achieve a highlight with a tween service like this model that i got!
    The video

  2. What is the issue?
    I tried putting a part of the script into another part for it too work but it didn;t, idk what i did wrong.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I did but didn’t find anything :(.

local tweenservice = game:GetService("TweenService")
local runservice = game:GetService("RunService")

local model = script.Parent

local cD = model.HandlePart.ClickDetector

local isOpen = false

local highlight = Instance.new("Highlight")
highlight.Parent = model
highlight.OutlineTransparency = 1
highlight.FillTransparency = 1

local Startpoint = model.Parent.Parent.Startpoint
local Endpoint = model.Parent.Parent.Endpoint

cD.MouseHoverEnter:Connect(function()
	local goaltween = {}
	goaltween.OutlineTransparency = 0
	
	local tI = TweenInfo.new(0.5, Enum.EasingStyle.Quint)
	
	tweenservice:Create(highlight, tI, goaltween):Play()
end)

cD.MouseHoverLeave:Connect(function()
	local goaltween = {}
	goaltween.OutlineTransparency = 1

	local tI = TweenInfo.new(0.5, Enum.EasingStyle.Quint)

	tweenservice:Create(highlight, tI, goaltween):Play()
end)

cD.MouseClick:Connect(function()
	if isOpen == false then
		tweenservice:Create(model.Parent.Base, TweenInfo.new(0.5, Enum.EasingStyle.Quint), {Position = Endpoint.Position}):Play()
		model.Parent.Base["Drawer Open"]:Play()
		
		isOpen = true
		
	else
		tweenservice:Create(model.Parent.Base, TweenInfo.new(0.5, Enum.EasingStyle.Quint), {Position = Startpoint.Position}):Play()
		model.Parent.Base["Drawer Close"]:Play()
		
		isOpen = false
	end
end)

What part do you guys suggest for it too make the highlight and the tween like in the script, but not like pull or do anything, just hover over and highlight with the tween service!

The tweens seem correct. Where is this script located? Try adding a print in every event (MouseHoverEnter, MouseHoverLeave, MouseClick) and see if they are even firing in the first place

1 Like

Screenshot 2024-07-15 170545
Here is the screenshot of everything!

By the way I still haven’t understood the issue as your OP wasn’t very clear: does the highlight not work at all?

1 Like

It doesnt work at all.

And also here is the Output of the print every event!

The print thingies work, means the script is working

If you would like the model too test things out, here you go!
Highlight.rbxm (12.7 KB)

What exactly is the problem? It seems to work from what I’ve downloaded.

No there Isn’t any problem with the File that i have sent.
I’m trying too find if the script will work at a part or any model, i dont want it too be with a click detector or proximity prompt or anything.
I just need it too be Hovering over and like the tween in the file i sent, like hover over and highlight ease’s in, and Hover out and the highlight ease’s out

Sorry you didn’t make that very clear. So you don’t want to be able to open the drawer but retain the highlights?

Well in this case, i’m pretty sure there’s no way to check for mouse hovering without using an additional instance such as a clickdetector. Why do you not want to use it?

No no, btw sorry for all the confusion. Im trying too make ONLY a hover highlight, like hover in and out, for ex i put my mouse inside the part, it does the tween service and highlights it like in the file i have sent. i just want it too highlight while hovering!

I also have this model that one of me friends have made, It is a hover over and instant highlight, just want too make it like the file i have sent, ill send the model

Or maybe like this model someone made
Hightlight new.rbxm (8.3 KB)

In that case you’ll probably need to use a client sided script and use something like Mouse.Target and check it every time it is moved to see if it’s something you want to highlight?? I am still a little confused as to why you’d want to do this though.

1 Like

Looks like they’ve done what I described

They have!
I just need too do it with the tween service and test it out

Im too stupid.

local player = game.Players.LocalPlayer
repeat task.wait(1) until player.Character
local character = player.Character
local mouse = player:GetMouse()

local CollectionService = game:GetService("CollectionService")

local maximumDistance = 25

mouse.Move:Connect(function()
	
	if not mouse.Target then script.Highlight.Adornee = nil return end
	if(mouse.Target.Position - character.HumanoidRootPart.Position).Magnitude > maximumDistance then script.Highlight.Adornee = nil return end 
	
	if CollectionService:HasTag(mouse.Target, "Highlightable") then
		script.Highlight.Adornee = mouse.Target
		return
	elseif CollectionService:HasTag(mouse.Target.Parent,"Highlightable") then
		script.Highlight.Adornee = mouse.Target.Parent
		return
	end
	
	script.Highlight.Adornee = nil
	
end)

ocal Startpoint = model.Parent.Parent.Startpoint
local Endpoint = model.Parent.Parent.Endpoint

cD.MouseHoverEnter:Connect(function()
	local goaltween = {}
	goaltween.OutlineTransparency = 0

	local tI = TweenInfo.new(0.5, Enum.EasingStyle.Quint)

	tweenservice:Create(highlight, tI, goaltween):Play()
	print('MouseHoverEnter')
end)

cD.MouseHoverLeave:Connect(function()
	local goaltween = {}
	goaltween.OutlineTransparency = 1

	local tI = TweenInfo.new(0.5, Enum.EasingStyle.Quint)

	tweenservice:Create(highlight, tI, goaltween):Play()
	print('MouseHoverLeave')
end)

cD.MouseClick:Connect(function()
	if isOpen == false then
		tweenservice:Create(model.Parent.Base, TweenInfo.new(0.5, Enum.EasingStyle.Quint), {Position = Endpoint.Position}):Play()
		model.Parent.Base["Drawer Open"]:Play()

		isOpen = true
		print("MouseClick")
	else
		tweenservice:Create(model.Parent.Base, TweenInfo.new(0.5, Enum.EasingStyle.Quint), {Position = Startpoint.Position}):Play()
		model.Parent.Base["Drawer Close"]:Play()

		isOpen = false
	end
end)

What do yall suggest?
Im open for all suggestions!