Script not working when copied?

I have this script

--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 = Vector3.new(0,31,0)

camera.CameraType = Enum.CameraType.Scriptable
local debounce = false
local function onRenderStep()
	if debounce == false then
		debounce = true

		if player.Character then
			if camera.CameraType == Enum.CameraType.Scriptable then
				print("e")
				local CAMERA_OFFSET = player.Character:WaitForChild("CameraOffset").Value
				local playerPosition = player.Character.Torso.Position
				local cameraPosition = playerPosition + CAMERA_OFFSET

				-- make the camera follow the player
				camera.CoordinateFrame = CFrame.new(cameraPosition, playerPosition)
			end
			if camera.CameraType == Enum.CameraType.Fixed then
				local CAMERA_OFFSET = player.Character:WaitForChild("CameraOffset").Value
				local playerPosition = player.Character.Torso.Position
				local cameraPosition = playerPosition + CAMERA_OFFSET

				-- make the camera follow the player
				camera.CoordinateFrame = CFrame.new(cameraPosition, playerPosition)
				repeat wait() until camera.CameraType ~= Enum.CameraType.Fixed
			end
		end
		debounce = false
	end
end
RunService:BindToRenderStep("Camera", Enum.RenderPriority.Camera.Value, onRenderStep)

I tried copying this LocalScript over to another game, It does not work anymore, doesn’t even change the cameratype, returns no error, and if i change the cameratype manually it prints out e once with no visible change.

1 Like

Do you have “CameraOffset” in the player’s Character? it can get caught in an infinite yield if you don’t…

2 Likes

Forgot to change that to the specific value lol thank you.

1 Like