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

Is there a way to reset the default mouse cursor?

Asked by
Klamman 220 Moderation Voter
8 years ago

I'm making a custom clickdetector script, and I'm changing the mouse icon to the ROBLOX one for clickdetectors whenever a certain part is under the mouse. However, I want the mouse to function normally after the mouse's target is no longer the brick. How can achieve this? My current code:

mouse.Move:connect(function()
    if player.Character.Humanoid.Health ~= 0 then
        if mouse.Target then
            local target = mouse.Target
            if target:IsDescendantOf(parts) then
                print(target)
                if mouse.Icon ~= "http://www.roblox.com/asset/?id=433782737" then
                    mouse.Icon = "http://www.roblox.com/asset/?id=433782737"
                end
            elseif not target:IsDescendantOf(parts) then
                --mouse.Icon
            end 
        end
    end
end)

Thanks in advance.

1 answer

Log in to vote
2
Answered by
Pyrondon 2089 Game Jam Winner Moderation Voter Community Moderator
8 years ago

All you have to do is set mouse.Icon to an empty string:

mouse.Move:connect(function()
    if player.Character.Humanoid.Health ~= 0 then
        if mouse.Target then
            local target = mouse.Target
            if target:IsDescendantOf(parts) then
                print(target)
                if mouse.Icon ~= "http://www.roblox.com/asset/?id=433782737" then
                    mouse.Icon = "http://www.roblox.com/asset/?id=433782737"
                end
            elseif not target:IsDescendantOf(parts) then
                mouse.Icon = ""
            end 
        end
    end
end)

Hope this helped.

0
Thanks! Klamman 220 — 8y
0
No problem. Pyrondon 2089 — 8y
Ad

Answer this question