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

How do I change the cursor of an item?

Asked by 9 years ago

I've got some gear in my game, that has no crosshair image (it's just the blue circle thing). How do I change the crosshair for the gear?

2 answers

Log in to vote
2
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

The crosshair for any gear you see in a game, is actually just a custom mouse.Icon. The Icon Property of the mouse is whatever your cursor will show up as(:

So to edit the crosshairs of a gear, simply edit the mouse's Icon.

Example;

local template = 'rbxassetid://' --The template for the icon
local icon = '0000000' --The actual ID to set your icon as
local default = '' --The default icon for the mouse
local tool = script.Parent --The tool

--When the tool is equipped
script.Parent.Equipped:connect(function(mouse)
    --Set the icon
    mouse.Icon = template..icon
    --When the tool is unequipped
    script.Parent.Unequipped:connect(function()
        --Revert the icon
        mouse.Icon = template..default
    end)
end)

(NOTE) The mouse's Icon can only be set from a localscript!

0
OK, thanks. This helps alot :) rootfridge 0 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

Just as an additional thing, what do you mean by a "template"?

0
In the future, just comment on my answer.. don't make another answer. And by template i mean the base for the ID. The ID is always going to have rbxassetid:// in it for it to be an ID. Look at decals - they don't only have the ID number, there's the 'template' there too. It's hard to explain but it's an essential for setting the ID. Goulstem 8144 — 9y
0
oh, ok. thanks. i'm new here. rootfridge 0 — 9y
0
is the template like this? Crosshair-item?id=96343638 rootfridge 0 — 9y
0
No, that's part of the URL for the actual Decal. You see those numbers on the end? Those are the ID for the decal, the template just always comes before the ID(: So you would go 'rbxassetid://96343638' if you wanted to use that.. or in the code I provided just replace the 'icon' value with '96343638'. Goulstem 8144 — 9y

Answer this question