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

How to change the mouse cursor back to normal?

Asked by 8 years ago

Can anyone tell me how to change the player's cursor back to normal? The error I keep getting with the code below is attempt to index local 'mouse' (a nil value) on line 8. I've also tried Mouse.Icon = "" but that doesn't work either.

Code I've tried using:

local Tool = script.Parent

Tool.Equipped:connect(function(Mouse)
    Mouse.Icon = "http://www.roblox.com/asset/?id=131581677"
end)

Tool.Unequipped:connect(function(Mouse)
    Mouse.Icon = "http://www.roblox.com/asset/?id=0"
end)

Any help appreciated.

1 answer

Log in to vote
0
Answered by
gskw 1046 Moderation Voter
8 years ago

Unequipped doesn't pass the Mouse to listening functions while Equipped does. You want to use the :GetMouse() function.

local Tool = script.Parent

Tool.Equipped:connect(function(Mouse)
    Mouse.Icon = "http://www.roblox.com/asset/?id=131581677"
end)

Tool.Unequipped:connect(function()
    game.Players.LocalPlayer:GetMouse().Icon = "" -- Also, use an empty string here so that it doesn't cause any unnecessary errors
end)

Ad

Answer this question