Skip to content
This repository was archived by the owner on Jul 16, 2024. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions lib/debugger/mouseHighlight.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@ local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

function getInstanceOnMouse()
local camera = workspace.CurrentCamera
if not camera then
return
end

local mouseLocation = UserInputService:GetMouseLocation()
local ray = camera:ScreenPointToRay(mouseLocation.X, mouseLocation.Y)

local result = workspace:Raycast(ray.Origin, ray.Direction * 1000)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1000 seems like a sensible length, but not sure.

return result and result.Instance
end

local function mouseHighlight(debugger, remoteEvent)
if not RunService:IsClient() then
error("Hovering can only be checked on the client")
Expand All @@ -10,10 +23,9 @@ local function mouseHighlight(debugger, remoteEvent)
local lastSent, setLastSent = debugger.plasma.useState()

if UserInputService:IsKeyDown(Enum.KeyCode.LeftAlt) then
local mouse = Players.LocalPlayer:GetMouse()
local instance = mouse.Target
local instance = getInstanceOnMouse()

if mouse.Target then
if instance then
local id
while instance.Parent do
id = instance:GetAttribute(debugger:_isServerView() and "serverEntityId" or "clientEntityId")
Expand Down