Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

function hover(), script.Parent.MouseEnter:connect(hover) not functioning?

I am currently trying to make a IntroGui. To add some effects to the TextButton I added MouseEnter and MouseLeave. But when I test the TextButton, it does not appear anymore.

Here is a link to my other question which was resolved just in case:

https://scriptinghelpers.org/questions/41898/textbuttonvisible-true-not-working

Script:

local TextButton = script.Parent
local Frame = TextButton.Parent
local TextLabel = Frame:WaitForChild('TextLabel')
local TextLabel1 = Frame:WaitForChild('TextLabel1')
local Frame1 = Frame:WaitForChild('Frame1')
local ImageLabel = Frame:WaitForChild('ImageLabel')
local Sound = Frame:WaitForChild('Sound')

wait(10)
TextButton.Visible = true
TextButton.MouseButton1Click:connect(function()
	for i = 0,0.5,1 do
		Frame.Visible = false
		TextLabel.Visible = false
		TextLabel1.Visible = false
		ImageLabel.Visible = false
		TextButton.Visible = false
		Frame1.Visible = false
		wait(0.05)
	end
	Sound:Stop()
	
end)

function hover()
	game.StarterGui.IntroGui.TextButton.BackgroundColor3 = (80,80,80)
	wait(0.05)
	
end
function hover2()
	game.StarterGui.IntroGui.TextButton.BackgroundColor3 = (50,50,50)
	wait(0.05)
end)

script.Parent.MouseEnter:connect(hover)
script.Parent.MouseLeave:connect(hover2)

Please help me, thank you!

3 comments

1

When you say, "it does not appear anymore," do you mean that the textbutton does not turn visible or do you mean that the effect isn't showing? If you mean the latter, then I recommend that instead of using "game.StarterGui.IntroGui.TextButton", you should use "TextButton" or script.Parent because the StarterGUI is not actually where the Player's GUIs are located.

0

The TextButton doesn't turn visible. But I fixed it from the answer below by RubenKan but it won't change color when I hover over the TextButton.

0

That'd be because you change starterGui and not PlayerGui

2 answers

✓ Accepted answer

You'll have to use Color3.fromRGB(r,g,b) instead of your (80,80,80) and (50,50,50)

Example:

Color3.fromRGB(80,80,80)

The wait is also not needed.

3 comments

0

I tried it and it either says Color3 is not a valid member of TextButton or when I chnage the Color3 to BackgroundColor3 it says fromRGB is not a valid member from Color3.

0

BackgroundColor3 = Color3.new(80,80,80)

0

^that won't work. it'd be Color3.new(80/255,80/255,80/255) wich is why i support Color3.fromRGB(80,80,80)

  1. Your for loop will not work, and even if it did, it's not needed. Get rid of it.

  2. StarterGui is not active; it is the template that clones into each player. Use PlayerGui. Or if that button equals the button you already defined, use that.

  3. You do not need to wait(0.05) so much.

  4. There is no Lua datatype that uses (#,#,#). Like RubenKan said, BackgroundColor3 requires a Color3 object.

To be frank you really should learn basic Lua before scripting.

local TextButton = script.Parent
local Frame = TextButton.Parent
local TextLabel = Frame:WaitForChild('TextLabel')
local TextLabel1 = Frame:WaitForChild('TextLabel1')
local Frame1 = Frame:WaitForChild('Frame1')
local ImageLabel = Frame:WaitForChild('ImageLabel')
local Sound = Frame:WaitForChild('Sound')

wait(10)
TextButton.Visible = true
TextButton.MouseButton1Click:connect(function()
    Frame.Visible = false
    TextLabel.Visible = false
    TextLabel1.Visible = false
     ImageLabel.Visible = false
    TextButton.Visible = false
    Frame1.Visible = false
    wait(0.05)
    Sound:Stop()
end)

function hover()
    TextButton.BackgroundColor3 = Color3.fromRGB(80,80,80)
end
function hover2()
    TextButton.BackgroundColor3 = Color3.fromRGB(50,50,50)
end)

script.Parent.MouseEnter:connect(hover)
script.Parent.MouseLeave:connect(hover2)

This discussion is preserved as it was. New answers, comments, and votes are closed.