function aa() while wait() do if script.Parent.TextButton.MouseEnter then print("A") end end end aa()
I know theres a function called MouseEnter, but I need an if statement and not a function. How would I make it work?
GuiObject.MouseEnter
is not a property or a function.
It's an event.
You can listen for this event.
lua
textButton.MouseEnter:Connect(function(x, y)
print(string.format("Player clicked at coordinates: (%d, %d)", x, y));
end);
The x
and y
parameters are the 2D X-Y coordinates of the mouse when hovered over the button
I misunderstood your question the first time.
What you can do is have a variable, it will start off as false
, set it to true when they are hovering over the button, false when they stop.
```lua local isHovering = false;
textButton.MouseEnter:Connect(function(x, y) isHovering = true; end);
textButton.MouseLeave:Connect(function(x, y) isHovering = false; end); ```
If you need to check that they are hovering...
lua
if (isHovering) then
--// do something...
end
Do not use while wait() do
. It only works because of a hack; a trick. Use
lua
while true do
...
end
It's clearer.
Hello, when I script UI's I like to be precise like you. Therefore you may use the following script to achieve the result:
pointer = game:GetService("UserInputService") -- now we do the script, very easy function response(theTextBox) -- your code end if pointer.TextBoxFocused:Wait() then -- I'm not sure if wait is a one-off thing... pointer.TextBoxFocused:Connect(response) end -- the TextBoxFocusReleased is the reverse