Is there any possible way to know whether a part is within your line of sight? I have looked around in the Wiki, and I haven't found anything of the sort... So if there is any way to create a method that can detect objects within your sight (detect whether the player can see the object or not), that'd be nice to know! Thanks in advance!
Here I'll help u out
Btw this was done by IPad so sorry if there were any errors or simple mistakes
Make a local script put In startergui
local Player = game.Playera.LocalPlayer local Camera = Workspace.CurrentCamera local FOV = Camera.FieldOfView -- FOV = FieldOfView local Parts = {} -- leave empty if u don't know what u are doing Scan = function(object) for i, v in pairs(object:GetChildren()) do table.insert(Parts, v) if #v:GetChildren() > 0 then Scan(v) -- scan the object since it has children end end end Scan(Workspace) -- this will scan everything in the workspace function getNearestObject() for i, v in pairs(Parts) do if (Player.Character.Torso.Position - v.Position).magnitude < FOV then -- magnitude gets the distance between the 2 points return v end end end while wait() do -- continuos loop local object = getNearestObject() print(object.Name) -- objects name goes towards output end