Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make a camera part rotate around a character?

I have a camera when the player first spawns in that looks at their character while they customize. I am trying to make that camera rotate around the character but i dont know how. Can someone help me to an easy solution?

2 comments

0

ok

0

gimme... a while to look at how camera works

1 answer

the camera has a CoordinateFrame property which is basically the CFrame of the camera(Although the camera also has a CFrame property). We could use that to make the camera revolve around the player;

put this in StarterPack; it will toggle on and off when u right click

local plr = game.Players.LocalPlayer -- get player
local mouse = plr:GetMouse()

local customizing = false

local cam = workspace.CurrentCamera -- get camera

local hum
local root

plr.CharacterAdded:Connect(function(char)
	wait(.1) -- wait for character's internals to load
	hum = char:FindFirstChild("Humanoid")
	root = char:FindFirstChild("HumanoidRootPart")
end)

repeat wait(.1) until root ~= nil -- wait for the root and hum

 -- from this part on i practically copied the camera manipulation article from the wiki

function takeCamera()	
	local angle = 0
	
	while customizing do wait()
		cam.CoordinateFrame = CFrame.new(root.Position) * CFrame.Angles(0,angle,0) * CFrame.new(0,200,500)
		angle = angle + math.rad(1)
	end
end

function returnCamera() -- this is to return the camera once the player is done customizing	
	cam.CameraSubject = hum
	cam.CameraType = "Custom"
end

mouse.Button1Down:Connect(function()
	if not customizing then
		customizing = true
		
		takeCamera()
	end
	
	if customizing then
		customizing = false
		
		returnCamera()
	end
end)

3 comments

0

Thanks, didn’t help though, I achieved my goal by putting a bodyangular in the humanoidrootpart(rotates the char rather than the camera)

0

legend

0

also u did ask help to revolve the camera around the character and not the opposite but ok

This discussion is preserved as it was. New answers, comments, and votes are closed.