Hello everyone, sorry for my bad english.
i’ve been trying to make a scriptable camera, make camera rotate and the body rotate , but the camera z orientation doesn’t stays in 0.
this is the code:
local camera = workspace.CurrentCamera
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local part = character.Part
local cameraSensitivity = 1
humanoid.AutoRotate = false
uis.InputChanged:Connect(function(input)
if (input.UserInputType == Enum.UserInputType.MouseMovement) then
local delta = input.Delta
rootPart.CFrame = rootPart.CFrame * CFrame.Angles(0, -math.rad(delta.X) * cameraSensitivity, 0)
part.CFrame = part.CFrame * CFrame.Angles(-math.rad(delta.Y) * cameraSensitivity,0,0)
end
end)
runservice:BindToRenderStep("camera", 201, function()
uis.MouseBehavior = Enum.MouseBehavior.LockCenter
camera .CameraType = Enum.CameraType.Scriptable
camera .CFrame = CFrame.new(rootPart.Position + Vector3.new(0, 2, 0)) * CFrame.Angles(math.rad(part.Orientation.X), math.rad(rootPart.Orientation.Y), 0)
part.Orientation = Vector3.new(part.Orientation.X,0, 0)
end)
I’ve already tried this and other things but none worked
camera.CFrame = CFrame.new(camera.CFrame.Position, Vector3.new(camera.CFrame.Rotation.X, camera.CFrame.Rotation.Y, 0))
That script just makes the camera not move.
How can i make so the camera z orientation stays in 0 but the x y orientation stills moves.
I’m not a professional scripter so if there is a way of making the code better tell me!