what i want to do is to make a function fire after looking at a part for a certain time for like 5-2 seconds but i couldnt get it working
i have tried using camera:WorldToScreenPoint() but i couldnt get it working
i want to make it so when u look at a part for to long you a function happens like for examples you die or get jumpscared
i couldnt figure out how to do it
thanks in advance.
I’d avoid using a camera for this. Instead, try raycasting:
local plyr: Player
local character: Model = plyr.Character
local a: Vector3 = character.PrimaryPart.Position
local b: Vector3 = part.Position
local direction: Vector3 = a - b
local result: RaycastResult = game.Workspace:Raycast(a, direction)
raycasting is simple but it wouldnt get the full screen like cam i want to check if the player looked at a part or is looking for too long and then fire a function after he looks at a part for to long
I still would recommend raycasting, though.
You could periodically cast rays between the faces of the parts involved, then continually cast rays if a result is found.
This post describes how you can cast rays from one side of a part (contextually a player’s character’s face) to another part, which should help!