Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is this code not hiding the default ROBLOX cursor? [Solved]

Hi! - I use a center GUI for the crosshair, which renders the default cursor useless. However, upon clicking the mouse, the cursor overlays the crosshair. I've set up a basic script that attempts to do that - but the cursor still comes up when the player clicks.

local Player = Game.Players.LocalPlayer 
local Mouse = Player:GetMouse() 
Mouse.Icon = "rbxasset://textures/Blank.png"
Mouse.Button1Down:connect(function() 
	end)

How would I go about hiding the default ROBLOX cursor when the player clicks?

Thanks in advance, Dragon.

Perhaps I should also mention that is already inside of a Hopperbin.

2 answers

✓ Accepted answer

Instead of using that, use the MouseIconEnabled property of the UserInputService.

game:GetService("UserInputService").MouseIconEnabled = false --Hides the cursor
game:GetService("UserInputService").MouseIconEnabled = true --Shows the cursor

In case you're interested, here's some more stuff you can do with the mouse that you may have not known about. (The page says it's available on GT2, but I believe most of those features are now available on regular Roblox.)

1 comment

1

Thank you for the flawless response! This gave me many headaches - but it serves me right for using a 'dated' method.

As stated on the PlayerMouse article,

trying to set the Icon will result in an error


In order to set the Icon, you need to use a mouse derived from an equipped/selected Tool or HopperBin -- not the PlayerMouse gotten from GetMouse.

1 comment

0

Thank you, but the post by 2eggnog has provided me with a cleaner method. Thank you for pointing that for you me though - I was a moron to not have noticed it.

This discussion is preserved as it was. New answers, comments, and votes are closed.