I am trying to lock the camera behind the player so that they cannot move it, but can’t seem to figure out how this would be achieved. If somebody could help me figure it out, that would be great
I want the camera to be locked like this so that the player cannot move it at all;
So I believe I have to set the distance to 10 (not the DIST_FROM_PLAYER, but the actual distance, so the DIST_FROM_PLAYER value would be -10) and somehow rotate the camera 180 degrees. I tried changing the first two values (seperately) to 180 and that didn’t work. Any ideas?
then in the script you need to have a part where the camera should start and where it should face. You said in the post you want it locked behind the player, anyways here is the script i made it should give you some help:
--try using this in a local script
local RunService = game:GetService("RunService")
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera
local DIST_FROM_PLAYER = 10 -- decrease this to make the camera close and increase for vice versa
Camera.CameraType = Enum.CameraType.Scriptable
repeat RunService.Stepped:Wait() until Player.Character.PrimaryPart
RunService.RenderStepped:Connect(function()
Camera.CFrame = CFrame.new(Character.PrimaryPart.CFrame.Position+(-Character.PrimaryPart.CFrame.LookVector*DIST_FROM_PLAYER),Character.PrimaryPart.CFrame.Position)
end)
Add an invisible part or something but you need to defined where you want the character to face, then fill in the line in this code: (IT has to be a part)
--try using this in a local script
local RunService = game:GetService("RunService")
local Part = --insert the part that you want the camera to face here
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera
local DIST_FROM_PLAYER = 10 -- decrease this to make the camera close and increase for vice versa
local HEIGHT = 2--increase or decrease to change the height from the ground
Camera.CameraType = Enum.CameraType.Scriptable
repeat RunService.Stepped:Wait() until Player.Character.PrimaryPart
RunService.RenderStepped:Connect(function()
Camera.CFrame = CFrame.new(Character.PrimaryPart.CFrame.Position+(-Character.PrimaryPart.CFrame.LookVector*DIST_FROM_PLAYER),Part.Position)*CFrame.new(0,HEIGHT,0)
end)