Question Is it possible to detect if one player has another player is in there view?
Thanks
This script below will tell you all players in the client's view. This is done by using the :WorldToScreenPoint(Vector3)
method of the camera.
---LOCAL SCRIPT--- local Players = game:GetService'Players' local RunService = game:GetService'RunService' repeat RunService.RenderStepped:wait() until Players.LocalPlayer and Players.LocalPlayer.Character and workspace.CurrentCamera -- Wait until the stuff we need is here local camera = workspace.CurrentCamera local player = Players.LocalPlayer local character = player.Character function getPlayers() local tab = {} for i,v in next,Players:GetPlayers() do -- :GetPlayers() returns a table of all Players and only players if v ~= player then -- If the player isn't equal to the client's player table.insert(tab,v) end end return tab end function getPlayersInView(t) local tab = {} -- Create the table for i,v in next,t do if v and v:IsA("Player") and v.Character then -- Check if the value is a player and has a character local torso = v.Character:FindFirstChild'Torso' if torso then -- Check for a torso local screenCords,IsInView = camera:WorldToScreenPoint(torso.Position) -- Returns coordinates of the position mapped to screen coordinates along with a bool if the position is visible on the screen if IsInView then table.insert(tab,v) -- Add the value to the table end end end end return tab -- Return the table end while wait(2) do -- Only runs every 2 seconds local playersInView = getPlayersInView(getPlayers()) if #playersInView >= 1 then -- If the players in the camera's view are greater than or equal to 1 for i,v in next,playersInView do print(v.Name) end else print("No players in view") end end