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

How would I detect when a player is visible inside a 2d GUI on my screen?

Asked by
len_ny 8
6 years ago

I want to detect when an enemy player or any other player is visible, with me, the local player, locked in first person, inside a frame I have on my screen.

Lets say I am looking at someone with a Frame thats a small square, but big enough around the crosshair that it is larger then the crosshair, and when a player enters that bigger frame it prints "FOUND PLAYER: " and the player name, how could I detect when a player enters a frame on my screen, is it even possible?

local plr = game.Players.LocalPlayer
local screengui = Instance.new('ScreenGui')
local frame = Instance.new('Frame')
local mouse = plr:GetMouse()

function onEnter(gotPlrObj)
    if gotPlrObj ~= nil then
        print('FOUND PLAYER: ' .. gotPlrObj.Name)
    end
end

-- setup the frame and screengui

screengui.Name = "CatchPlayer"
screengui.Parent = plr.PlayerGui

frame.Name = "Frame"
frame.Parent = screengui

Answer this question