Camera viewpoint following on part when clicking on it part

so can anyone make script that when click on part, player camera viewpoint will following/stick on the part, I want to recreate some cool thing that my project was lose

like this, I’ll pick build a boat for example: https://youtu.be/YBnzbTEMTCk (can’t send video)

it like when click on dome camera it will following on the part that we’re clicked

1 Like

Create a server script which should be inside your chosen part:


local part = script.Parent
local clickDetector = part:FindFirstChild("ClickDetector") or Instance.new("ClickDetector")
clickDetector.Parent = part

local replicatedStorage = game:GetService("ReplicatedStorage")
local cameraEvent = replicatedStorage:WaitForChild("Camera")

clickDetector.MouseClick:Connect(function(plr)
	cameraEvent:FireClient(plr, part)
end)


Now, create a RemoteEvent in ReplicatedStorage named “Camera”.

Finally, attach a local script in StarterPlayer → StarterCharacterScripts with:


local replicatedStorage = game:GetService("ReplicatedStorage")
local cameraEvent = replicatedStorage:WaitForChild("Camera")

local camera = workspace.CurrentCamera

cameraEvent.OnClientEvent:Connect(function(part)
	if camera.CameraSubject == part then
		camera.CameraSubject = script.Parent.Humanoid
		camera.CameraType = Enum.CameraType.Custom
		return
	end
	camera.CameraSubject = part
	camera.CameraType = Enum.CameraType.Follow
end)

If you click the part, your camera will start following it. If you click the same part again, it will start following you again.

2 Likes

thank you!

but when the part has that script been duplicated/clone, it not worked

1 Like

There should only be one server script per part/model as two or more ClickDetectors may create problems.

If it still doesn’t work, could you elaborate further?

• How is the server script set up?
• Did you create the RemoteEvent?
• Is the local script placed in StarterPlayer —> StarterCharacterScripts?

1 Like

yes I did create remoteevent and I place local script in startercharacterscripts

the camera part is still functional even there has 2 or more (I guess) , but when it duplicated while studio was running/playing it not worked

1 Like

You’re duplicating the part locally, which is why it’s not working (Server scripts don’t work locally).

You should duplicate it in the server via Test → Current: …

  • The current view is located right beside the Play Button in the far left. When pressed, it will display either Client or Server.
  • To access the “Current View”, you have to press Play.

P.S. If you’re trying to get the same type of CameraType as Babft, I suggest using Enum.CameraType.Track instead of Enum.CameraType.Follow in your local script.

completely unrelated but you should probably learn and not just ask for scripts and how to do things. can’t just keep making new topics like your newest one:

i sense that you’re a beginner, and that’s ok. but again, it’s best you start learning on your own (with possible help from the forum) and then gain knowledge. then you can truly let out your own ideas!

1 Like

I put camera script on part that will clone itself then following player
I did replace “Enum.CameraType.Follow” to “Enum.CameraType.Track” in local script