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
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)
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.
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
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)
This discussion is preserved as it was. New answers, comments, and votes are closed.
3 comments
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.
i guess i mean mouse.hit.p
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.