You know, the one that appears when you hover over guis? I can only figure out how to change the default one.
Is it possible to change the black cursor texture with scripts?
1 answer
This only appears to happen upon hovering over GuiButton objects. And unfortunately, there is no way to prevent this.
But there is a way around it.
You could use a TextLabel, along with the Button1Down event, and check if the mouse is within the bounds of the GuiObject in order to simulate the MouseButton1Down event.
This would look like this;
local plr = game.Players.LocalPlayer;
local mouse = plr:GetMouse();
local gui = script.Parent;
local xBounds,yBounds = gui.AbsoluteSize.X,gui.AbsoluteSize.Y;
local xPos,yPos = gui.AbsolutePosition.X,gui.AbsolutePosition.Y;
mouse.Button1Down:Connect(function()
local x,y = mouse.X,mouse.Y;
local leftui,rightui = xPos-xBounds,xPos+xBounds;
local upui,downui = yPos+yBounds,yPos-yBounds;
if (x < rightui and x > leftui) and (y < upui and y > downui) then
print("MouseButton1Down");
end
end)
Essentially, you can get the bounds of the GuiObject by adding/subtracting the AbsoluteSize by the AbsolutePosition.
So, left side of the ui would be: AbsolutePosition.X - AbsoluteSize.X and the right side would be the same, but you add the AbsoluteSize rather than subtracting it. Same goes for the Y bounds.
Hope I helped! And happy developing!
This discussion is preserved as it was. New answers, comments, and votes are closed.
