Tween transparency on hover script doesn't work

Hello, I have just recently started getting back into developing on Roblox after a while and I’ve attempted to make a script that tweens the transparency a few frames and a text label when you hover over a part containing a SurfaceGui, though it doesn’t seem to work.

Script:

local note = workspace:WaitForChild("Spawn"):WaitForChild("House1"):WaitForChild("Note")
local hover = script.Parent:WaitForChild("Hover")

local frame = script.Parent:WaitForChild("Frame")
local frame2 = script.Parent:WaitForChild("Frame1")


note.MouseEnter:Connect(function()
	
	local TweenService = game:GetService("TweenService")
	
	script.Parent.Enabled = true
	
	TweenService:Create(hover, TweenInfo.new(0.5), {TextTransparency = 0}):Play()
	TweenService:Create(frame, TweenInfo.new(0.5), {BackgroundTransparency = 0}):Play()
	TweenService:Create(frame2, TweenInfo.new(0.5), {BackgroundTransparency = 0}):Play()
	
end)

note.MouseLeave:Connect(function()
	
	local TweenService = game:GetService("TweenService")
	
	TweenService:Create(hover, TweenInfo.new(0.5), {TextTransparency = 1}):Play()
	TweenService:Create(frame, TweenInfo.new(0.5), {BackgroundTransparency = 1}):Play()
	TweenService:Create(frame2, TweenInfo.new(0.5), {BackgroundTransparency = 1}):Play()
	
    wait(0.5)
    script.Parent.Enabled = false
end)
(Screenshot)

Explorer:

The part you hover over:

The frames, text and script:

What am I missing? Did I do anything wrong?
Any help is appreciated.

1 Like

Just saw the issue, you’re calling a MouseEnter/MouseLeave event on a Part.
Use this code instead of yours:

local note = workspace:WaitForChild("Spawn"):WaitForChild("House1"):WaitForChild("Note")
local cd = note:WaitForChild("ClickDetector")
local hover = script.Parent:WaitForChild("Hover")

local frame = script.Parent:WaitForChild("Frame")
local frame2 = script.Parent:WaitForChild("Frame1")


cd.MouseHoverEnter:Connect(function()
	
	local TweenService = game:GetService("TweenService")
	
	script.Parent.Enabled = true
	
	TweenService:Create(hover, TweenInfo.new(0.5), {TextTransparency = 0}):Play()
	TweenService:Create(frame, TweenInfo.new(0.5), {BackgroundTransparency = 0}):Play()
	TweenService:Create(frame2, TweenInfo.new(0.5), {BackgroundTransparency = 0}):Play()
	
end)

cd.MouseHoverLeave:Connect(function()
	
	local TweenService = game:GetService("TweenService")
	
	TweenService:Create(hover, TweenInfo.new(0.5), {TextTransparency = 1}):Play()
	TweenService:Create(frame, TweenInfo.new(0.5), {BackgroundTransparency = 1}):Play()
	TweenService:Create(frame2, TweenInfo.new(0.5), {BackgroundTransparency = 1}):Play()
	
    wait(0.5)
    script.Parent.Enabled = false
end)

This worked, thank you so much!

1 Like

No problem my dude! If you need any help you can private message me, I’ll try to help!