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

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

Asked by 10 years ago

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.

Locked by 2eggnog, OniiCh_n, M39a9am3R, and Shawnyg

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

2 answers

Log in to vote
2
Answered by
2eggnog 981 Moderation Voter
10 years ago

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
Thank you for the flawless response! This gave me many headaches - but it serves me right for using a 'dated' method. HypocriticalDragon 40 — 10y
Ad
Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

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.

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. HypocriticalDragon 40 — 10y