I have a problem with this, I want the camera to stop before it hits a wall like this
So it would stop around here.
--Get service needed for events used in this script
local RunService = game:GetService("RunService")
-- Variables for the camera and player
local camera = workspace.CurrentCamera
local player = game.Players.LocalPlayer
player.CharacterAdded:Wait()
-- Constant variable used to set the camera’s offset from the player
local CAMERA_OFFSET = player.Character:WaitForChild("CameraOffset").Value
print(CAMERA_OFFSET)
camera.CameraType = Enum.CameraType.Scriptable
local function onRenderStep()
-- Check the player's character has spawned
if player.Character then
if camera.CameraType == Enum.CameraType.Scriptable then
local CAMERA_OFFSET = player.Character:WaitForChild("CameraOffset").Value
local playerPosition = player.Character.HumanoidRootPart.Position
local cameraPosition = playerPosition + CAMERA_OFFSET
-- make the camera follow the player
camera.CoordinateFrame = CFrame.new(cameraPosition, playerPosition)
end
end
end
RunService:BindToRenderStep("Camera", Enum.RenderPriority.Camera.Value, onRenderStep)
This is the script I am using for the camera.