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

mouse enter and mouse leave not functioning?

I am trying ot make a gui that highlights the gui the mouse is in,but it does not function or even produce an error Here is what my code reads:

local children = script.Parent:GetChildren()
for i,v in pairs(children) do
		if v:IsA("TextButton") then
			v.MouseEnter:connect(function()
				v.BorderSizePixel = 1
				v.BorderColor3 = Color3.new(0,255,255)
			end)
			v.MouseLeave:connect(function()
				v.BorderSizePixel = 0
			end)
			v.MouseButton1Click:connect(function(clicked)
					clicked.BorderSizePixel = 1
					clicked.BorderColor3 = Color3.new(0,255,255)
			end)
		end
	end


1 answer

✓ Accepted answer

--UPDATED and FIXED

This is your main script you showd:

--You have such a mess here o.o
local children = script.Parent:GetChildren() for i,v in pairs(children) do if v:IsA("TextButton") then 
local sr=script.MouseFunctions:Clone()
sr.Parent=v sr.Disabled=false
end end

Now make a script that is disabled inside that script called MouseFunctions:

local D=false
--What i realized is that your no-organization made your script eventually break...
script.Parent.MouseEnter:connect(function(x,y) -- This script is inside the textbuttons
-- for higher chance of working
script.Parent.BorderSizePixel = 1 
script.Parent.BorderColor3 = Color3.new(0,255,255) 
end) 
script.Parent.MouseLeave:connect(function(x,y)  -- X and Y are a property of MouseLeave and MouseEnter
if D==false then
script.Parent.BorderSizePixel = 0 end end) 
script.Parent.MouseButton1Click:connect(function(clicked)
D=true script.Parent.BorderSizePixel = 1 script.Parent.BorderColor3 = Color3.new(0,255,255) 
-- clicked is Mouse :_: u cant change Mouse's BorderSizePixel . . .
end)

Add a new ClickDetector into main script's Parent.

Hope this helps! If not tell output! ~marcoantoniosantos3

6 comments

0

It popped out ' MouseEnter is not a valid member of ClickDetector'

0

try now

0

-_- "MouseButton1Click is not a valid member of ClickDetector"..Line 1

0

MouseButton1Click is MouseClick... Change it to MouseClick and correct my answer

0

Does not work no output,you understand i want it to highlight text buttons right? not the frame?

0

yh

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