How do I make camera manipulation when a part is touched?

I would like to make the camera movement be from the top (like in the photo), but only when a part is touched.

If you look at the picture you’ll understand what I mean, during the game you have normal camera movements like any ROBLOX game but when you enter a specific room and touch this part it makes the camera look the same as in the photo (so you can’t freely move the camera around) and when you exit the room and touch another part it reverts the camera back to normal.

I’m sorry if I’m not explaining this well enough, but how do I make such a thing?

Please note I’m not a very good scripter, so being as thorough as possible is appreciated.

5 Likes

You would want this to be a LocalScript & probably easiest would be to have it in StarterCharacterScripts.

Using RunService.RenderStepped is best for camera as it runs every frame & as the first thing on every frame. Meaning it catches every change from the frame just prior:
https://developer.roblox.com/en-us/api-reference/event/RunService/RenderStepped
Here we have RunService referenced, a variable to say whether or not we’re in free camera or forced camera, and then RenderStepped function that forces the player’s CurrentCamera to be the CFrame location of a part’s position just inside workspace.

local RunService = game:GetService('RunService')

local CameraManipulated = false

RunService.RenderStepped:Connect(function()
	if CameraManipulated then
		workspace.CurrentCamera.CFrame = workspace.CameraPart.CFrame
	end
end)

image
image
Then we have the touch detector function. Inside is an if statement that checks if LocalPlayer is the same as the hit, making sure it’s you & nothing else it’s detecting. This puts the value to true. Then you can have a different touch function on another part to set it back to false.

workspace.PartToTouch.Touched:Connect(function(hit)
	if game.Players.LocalPlayer == game.Players:GetPlayerFromCharacter(hit.Parent) then
		CameraManipulated = true
	end
end)

Here’s a place file with a way to do it:
CameraManipulation.rbxl (38.0 KB)

6 Likes

You’re the best, thank you so much this is very helpful!!

3 Likes