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

Is it possible to change the black cursor texture with scripts?

Asked by 8 years ago

You know, the one that appears when you hover over guis? I can only figure out how to change the default one.

1 answer

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
8 years ago
Edited 8 years ago

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;

01local plr = game.Players.LocalPlayer;
02local mouse = plr:GetMouse();
03local gui = script.Parent;
04local xBounds,yBounds = gui.AbsoluteSize.X,gui.AbsoluteSize.Y;
05local xPos,yPos = gui.AbsolutePosition.X,gui.AbsolutePosition.Y;
06 
07mouse.Button1Down:Connect(function()
08    local x,y = mouse.X,mouse.Y;
09    local leftui,rightui = xPos-xBounds,xPos+xBounds;
10    local upui,downui = yPos+yBounds,yPos-yBounds;
11    if (x < rightui and x > leftui) and (y < upui and y > downui) then
12        print("MouseButton1Down");
13    end
14end)

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!

Ad

Answer this question