What do I want to achieve?
Basically, the player is able to move his camera in different directions/angles. I would like to create a button which resets the camera behind the character’s head once clicked. Is that possible?
What is the issue?
I tried many times with different methodes but nothing seems to work.
What solutions have you tried so far?
I tried to search on the Internet and on the DevForum but without any answer to my struggle so far.
I would like to know if anyone knows how to do that, or at least the functions and/or processes needed to reach that effect.
I hope the way I explained what I want seems clear to you all. Thanks by advance for your help!
You can still change the CFrame of the player’s camera while it’s being controlled by the player. It will just cause the camera to “line up” with whatever location you set it to.
So, in theory, all you need to do is get the orientation of the player’s head, and then set the camera’s CFrame to that orientation.
local lp = game:GetService('Players').LocalPlayer
local angleOffset: CFrame = CFrame.Angles(math.rad(-30), 0, 0) --tilt the camera down a bit
script.Parent.MouseButton1Click:Connect(function()
local char = lp.Character
if char then
local head: BasePart = char:FindFirstChild('Head')
if head then
workspace.CurrentCamera.CFrame = head.CFrame*angleOffset
end
end
end)