Well first of all you have 2 Big Mistakes and I want you to fix them!
You don’t need to loop using while true do, since you are already looping with RenderStepped event.
So there is an option where you can connect your function to the RenderStepped event.
local RunService = game:GetService("RunService")
RunService.RenderStepped:Connect(function()
-- Code that will update every frame like setting your Camera CFrame every single Frame!
end)
You are checking for a character which is good, since local scripts can be outrun super fast and code might reach the main code.
Now I have a question for you since I actually tested this code and in my Studio it seems to be working! I wonder if it has something to do with the Character type, since mine was R15 and yours is R6, if not then there might be another script that overrides your character controls.
Did you try it with R15?
Did you check any other scripts that could be overriding your character controls?
Okay I figured the problem I will be updating the reply and show a script and explain everything in few moments.
Update 1:
-- // Services
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
-- // Settings
local FOV = 10
local Distance = 100
-- // Code
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local Camera = game.Workspace.CurrentCamera
Camera.FieldOfView = FOV
if Camera.CameraType ~= Enum.CameraType.Scriptable then Camera.CameraType = Enum.CameraType.Scriptable end
RunService.RenderStepped:Connect(function()
local X_Distance = HumanoidRootPart.Position.X + Distance
local Y_Distance = HumanoidRootPart.Position.Y + Distance
local Z_Distance = HumanoidRootPart.Position.Z + Distance
local Vector = Vector3.new(X_Distance, Y_Distance, Z_Distance)
if Character then
print("Check")
Camera.CFrame = CFrame.new(Vector, HumanoidRootPart.Position)
end
end)
I have updated your script and organized it even more, one of the things you need to know is that you need to wait for the CharacterAdded event to be able to get the character, since as I said before, local scripts run very fast, so they might as well not find your character!
I tested your code the first time and I could turn around when I hold Right Mouse Button Click, but while updating your code, it seems that whenever I hold RMB it will just simply rotate my character like shift lock???
Didn’t happen the first time, but now it’s happening, I tried using your code again and it does same thing over and over I can’t really be sure how to fix it unless…
Note: Don’t state my post as a solution, since I haven’t found the solution to something you have. The problem is very weird.