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

How to make a part not send mouse.hit information?

Asked by 5 years ago
Edited 5 years ago

So basically I want to be able to make parts not trigger mouse.hit.p when they are hovered over, like if they were not there (I still want to be able to see them)

  • I want to be able to get mouse.hit.p of parts behind that object
0
Do you mean mouse.Target, because mouse.Hit returns the CFrame position of the mouse in the world, with it's sister argument, mouse.Hit.p return the Vector3 position of the mouse in the world. SimplifiedCode 227 — 5y
0
i guess i mean mouse.hit.p Ido_nothaveUsername 213 — 5y
0
Sounds like you want Roblox to ignore the part when calculating mouse.Hit.Position. The API isn't working atm but I think there's some sort of "Filter" property on the mouse. You can also use UserInputService and some of the functions on Workspace to raycast ignoring specific objects. chess123mate 5873 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

There is a property on the mouse called "TargetFilter" you can basically set this if you want the mouse to simply ignore something.

Example:

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local RunService = game:GetService("RunService")

RunService.RenderStepped:Connect(function()
    if (Mouse.TargetFilter ~= workspace) then
        Mouse.TargetFilter = workspace
    end
end)

Let's say you made a teleport on click script, if my targetfilter was set to workspace then I would have been teleported nowhere.

Ad
Log in to vote
1
Answered by 5 years ago

So, the first thing I would do is set mouse.hit.p as a variable, and when I don't want that variable to be the mouse position, I would set that variable to an empty Vector3.

-- Local Script
local mouse = game.Players.LocalPlayer:GetMouse() -- get the local player's mouse
local wantMousePosition = false

mouse.Move:Connect(function() -- fire the code below when the mouse moves
    local mousePosition = mouse.Hit.p -- set the mousePosition to a variable
    if wantMousePosition == false then -- check if we want the mouse position
        local mousePosition = Vector3.new() -- we do not want the mouse position so we set the mouse position to an empty Vector3
    end 
end)

If this helped, please upvote

0
I think you are misunderstanding the question, I still want the mouse.hit.p but of the parts behind that object(as if the item wasn't there) Ido_nothaveUsername 213 — 5y

Answer this question