How to make local camera turn and look to position on touch?

Im not good in scripting gui and camera system, and i want to do a thing for a scary mechanic.
I want to make a script where belongs to a part, if we touch the part, the players camera will turn to a position (with tween [smoothly]) like a zombie, an explosion.

I looked to dev hub but i couldnt find anything i want.

1 Like

I think these on the roblox documentation will help, the first is for moving the camera around.

And this one is for getting if the player collides or touches an object.

You could combine both of these to move the camera towards the position that you want to.

1 Like

So from the touched event you can get the player instance using the basepart parameter and doing game.Players:GetPlayerfromcharacter(model). Then if you know how to use remote events fire a remote event to the client with the given player instance. Then get the client’s camera by doing workspace.CurrentCamera and set the camera type to Enum.CameraType.Scriptable so you can add in custom behaviour like tweening it to a position. Then if you know how to tween just tween the camera’s cframe to the part’s cframe, offset the cframe a bit if you want. Some people may recommend lerping the camera’s cframe but I wouldn’t personally because it wouldn’t be as smooth I think, using a for loop wouldn’t be as smooth and relying on something like runservice.RenderStepped would be a bad idea because if the player is laggy it will affect the smoothness.

1 Like