Roblox Scripting Help, mouse.target on mobile?

Hello Parzival_Pizza here, ive been trying to work on a game where if the centre of the camera is looking in at any area of a part. it will do something. But seeing im aiming this game towards mobile, this doesn’t seem to work.

I have tried using the mouse.target, but that doesn’t seem to work on mobile, but it works on PC. I have also tried locking the mouse in the centre, works on laptop, but not on mobile.

Is there any way of doing this?

2 Likes

you could try raycasting :thinking: are you trying to tap on a part, or detect if it’s field of view? i’m kinda confused by your wording.

im trying to check if something is in the near the centre of the screen(client) and if there is, something will happen

1 Like

does the script know what these objects are? because if so you can do some simple trig to calculate angular difference between the lookVector of the camera and the positional differences of the camera and the object.

I spent a couple of seconds searching and found topics. Make sure you do the same in the future. Query is something along the lines of an alternative for mouse.Target.

Thread list (some are threads, some are directly to the replies)
6 Likes

i did research, but i dont believe the right topics

There’s your list now. Take a bit to read through those threads. They have alternatives to using mouse.Target that you should adopt for both mobile and computers.

You can use Camera | Documentation - Roblox Creator Hub to determine if a part is visible on screen

You can also get the width and height of the screen using Mouse. The center of the screen is Mouse.ViewSizeX/2, Mouse.ViewSizeY/2.

Compare the position of the part onscreen and the center of the screen. If the two values are close enough, count that part as being “looked at”