EDIT: I fixed it!!! Check replies
Hey! I’m having some issues with a camera system I’m working on. The camera is meant to be in first person, while also being able to “focus” on objects, and then exit focus mode and return to first person.
Here’s my focus mode code:
FocusEvent.OnClientEvent:Connect(function(object)
if object:GetAttribute("FocusCamPos") then
if BoundFunction then
RunService:UnbindFromRenderStep(BoundFunction)
end
playerCframe = Camera.CFrame
CamPart.CFrame = playerCframe
root.Anchored = true
repeat
task.wait()
Camera.CameraType = Enum.CameraType.Scriptable
until
Camera.CameraType == Enum.CameraType.Scriptable
BoundFunction = "FocusIntro"
local targetFrame = CFrame.lookAt(object:GetAttribute("FocusCamPos"), object.Position)
local tween = TweenService:Create(CamPart, tweenInfo, {CFrame = targetFrame})
tween:Play()
RunService:BindToRenderStep(BoundFunction, Enum.RenderPriority.Camera.Value + 1, function()
Camera.CFrame = CamPart.CFrame
end)
tween.Completed:Wait()
BoundFunction = "Focus"
local maxTilt = script:GetAttribute("MaxTilt")
RunService:BindToRenderStep(BoundFunction, Enum.RenderPriority.Camera.Value + 1, function()
Camera.CFrame = CamPart.CFrame * CFrame.Angles(
math.rad((((mouse.Y - mouse.ViewSizeY / 2) / mouse.ViewSizeY)) * -maxTilt),
math.rad((((mouse.X - mouse.ViewSizeX / 2) / mouse.ViewSizeX)) * -maxTilt),
0
)
end)
end
end)
Here’s the first person mode code:
local function FirstPerson()
if BoundFunction then
RunService:UnbindFromRenderStep(BoundFunction)
end
if Camera.CameraType == Enum.CameraType.Scriptable then
local tween = TweenService:Create(CamPart, tweenInfo, {CFrame = playerCframe})
tween:Play()
BoundFunction = "FocusOutro"
RunService:BindToRenderStep(BoundFunction, Enum.RenderPriority.Camera.Value + 1, function()
Camera.CFrame = CamPart.CFrame
end)
tween.Completed:Wait()
RunService:UnbindFromRenderStep(BoundFunction)
end
root.Anchored = false
repeat
task.wait()
Camera.CameraType = Enum.CameraType.Custom
until
Camera.CameraType == Enum.CameraType.Custom
BoundFunction = "CameraSway"
RunService:BindToRenderStep(BoundFunction, Enum.RenderPriority.Camera.Value + 1, function(deltaTime)
local MouseDelta = UserInputService:GetMouseDelta()
Turn = Lerp(Turn, math.clamp(MouseDelta.X, -5, 5), (7 * deltaTime))
Camera.CFrame = Camera.CFrame * CFrame.Angles(0, 0, math.rad(Turn))
end)
end
This command is called at the start of the game automatically, so the issue is from switching back to first person mode, not the first person mode itself. I’ve also determined that the tween from focus mode back to first person is not the issue (by commenting it out), same with the camerasway code.
Heres a video of what happens:
I’ve also checked and confirmed that the player is properly unanchored (by walking around and switching to server view) so that’s not it either. Additionally, I’ve put prints at the boundfunction if loops and they are firing properly and unbinding the correct event (as far as i can tell). I’m honestly at a complete loss and any help is appreciated. Cheers!