Camera Sytem doesnt work on Mobile

You can write your topic however you want, but you need to answer these questions:

  1. **What do you want to achieve? Create a sytem which makes the player unable to use the camera/ rotation manually.

  2. **What is the issue? The code doesnt work for mobile. After about 90 degrees the character just stops spinning.

  3. **What solutions have you tried so far? Changed code about 20 times, asked ChatGPT, recoded the entire thing I NEED HELP

So basiclly I am creating an obby, in which the camera rotates (rotate script) and an other script(lock) makes it, that the player cant control the camera(rotate). That works fine for Laptop and PC but on Mobile the system messes up completly and idk why

rotate Script:

local player = game.Players.LocalPlayer
local runService = game:GetService("RunService")
local camera = workspace.CurrentCamera

local rotationSpeed = 1 -- Default value, replace or update as needed
local rotationConnection = nil

local function updateRotationSpeed()
	if rotationConnection then
		rotationConnection:Disconnect()
		rotationConnection = nil
	end

	if rotationSpeed > 0 then
		rotationConnection = runService.RenderStepped:Connect(function(deltaTime)
			camera.CFrame = camera.CFrame * CFrame.Angles(0, math.rad(rotationSpeed * deltaTime * 60), 0)
		end)
	end
end

player:GetAttributeChangedSignal("RotationSpeed"):Connect(function()
	rotationSpeed = player:GetAttribute("RotationSpeed") or 1
	updateRotationSpeed()
end)

updateRotationSpeed()

lock script:

local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local player = Players.LocalPlayer
local camera = workspace.CurrentCamera

-- Disable mouse and touch camera rotation
local function disableInputCameraRotation(input)
	if input.UserInputType == Enum.UserInputType.MouseMovement or
		input.UserInputType == Enum.UserInputType.Touch then
		UserInputService.MouseDeltaSensitivity = 0
	end
end

-- Ensure sensitivity remains 0
local function onInputEnded(input)
	if input.UserInputType == Enum.UserInputType.MouseMovement or
		input.UserInputType == Enum.UserInputType.Touch then
		UserInputService.MouseDeltaSensitivity = 0
	end
end

-- Update the camera position and align character rotation with camera
local function updateCameraAndCharacter()
	if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
		local rootPart = player.Character.HumanoidRootPart
		local cameraLookVector = camera.CFrame.LookVector

		-- Rotate the character to face the same direction as the camera
		local newRotation = CFrame.new(Vector3.new(), Vector3.new(cameraLookVector.X, 0, cameraLookVector.Z))
		rootPart.CFrame = CFrame.new(rootPart.Position) * newRotation
	end
end

-- Connect input events to disable camera control
UserInputService.InputChanged:Connect(disableInputCameraRotation)
UserInputService.InputEnded:Connect(onInputEnded)

-- Update camera and character rotation every frame
RunService.RenderStepped:Connect(updateCameraAndCharacter)

-- Ensure the settings persist across respawns
player.CharacterAdded:Connect(function()
	camera.CameraType = Enum.CameraType.Custom
end)

-- Initial setup
camera.CameraType = Enum.CameraType.Custom

Ty for the help
Bildschirmfoto 2024-08-04 um 00.41.04