I want the mouse to change into a hammer or wrench when it is pointing on a piece of wood. Please could I have help?
COMMUNITY QUESTION
How do I change the mouse cursor when it is pointing at a specific part?
1 answer
You have to use Mouse.Target
Example in a LocalScript:
--If you want that this script work you have to create a new folder in the workspace called "HoverParts"
local parts = workspace.HoverParts
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
while true do
wait()
if mouse.Target then --If the mouse target is not nil
if mouse.Target.Parent == parts then --If the part that you are hovering on is a child of the HoverParts folder in the workspace
mouse.Icon = "DECAL ID"
else
Mouse.Icon = ""
end
end
end
There are many ways to check if you are pointing at a specific part The way I showed you is kinda "bad" but it should work :D
This is a other way (with the part name):
local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
while true do
wait()
if mouse.Target then --If the mouse target is not nil
if mouse.Target.Name == "PointPart" then --If the target name is "PointPart"
mouse.Icon = "DECAL ID"
else
Mouse.Icon = ""
end
end
end
And you dont have to use "while true do"
You can just do
local uis = game:GetService("UserInputService")
uis.InputChanged:connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseMovement then
--The code
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Hi, you should do research and try to make your script before you go on scripting helpers.