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 7 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
7 years ago
Edited 7 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;

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!

Ad

Answer this question