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

If looking at brick statment? [closed]

Asked by 5 years ago
Edited 5 years ago

I am currently trying to make an event that occurs when a player looks at a brick, I've tried a lot of things, but none was successful, anyone?

0
Do you want to detect if the part is visible on the camera? Or if the player's character is generally looking at the part? For the first you can use WorldToScreenPoint(), and for the latter you could probably use dot product. SummerEquinox 643 — 5y

Closed as Too Broad by Leamir, IcyEvil, Vulkarin, and User#21908

This question has been closed because it is too broad and is generally unanswerable. Please ask a more specific question.

Why was this question closed?

1 answer

Log in to vote
0
Answered by 5 years ago

One "hacky" of doing this is using the Camera:WorldToScreenPoint method.


local m = game.Players.LocalPlayer:GetMouse() m.Button1Down:Connect(function() local camera = workspace.CurrentCamera local worldPoint = workspace.Baseplate.Position local vector, onScreen = camera:WorldToScreenPoint(worldPoint) print(onScreen) -- true if it's on the screen print(vector) end)

A problem with this can be found by AllYourBlox's post here

Ad