Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

mouse enter and mouse leave not functioning?

Asked by 9 years ago

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

Log in to vote
1
Answered by 9 years ago

--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

0
It popped out ' MouseEnter is not a valid member of ClickDetector' raspyjessie 117 — 9y
0
try now marcoantoniosantos3 200 — 9y
0
-_- "MouseButton1Click is not a valid member of ClickDetector"..Line 1 raspyjessie 117 — 9y
0
MouseButton1Click is MouseClick... Change it to MouseClick and correct my answer marcoantoniosantos3 200 — 9y
View all comments (2 more)
0
Does not work no output,you understand i want it to highlight text buttons right? not the frame? raspyjessie 117 — 9y
0
yh marcoantoniosantos3 200 — 9y
Ad

Answer this question