Hello, I have this script which allows for strafing:
local X_OFFSET = 5
local Y_OFFSET = 5
local Z_OFFSET = 10
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local LocalPlayer = game.Players.LocalPlayer
local CurrentCamera = game.Workspace.CurrentCamera
local Character = LocalPlayer.Character
local Humanoid = Character.Humanoid
local Root = Character.HumanoidRootPart
Humanoid.AutoRotate = false
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
CurrentCamera.CameraType = Enum.CameraType.Scriptable
local Tilt = 0
UserInputService.InputChanged:Connect(function(input)
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
if input.UserInputType == Enum.UserInputType.MouseMovement then
Tilt = Tilt + input.Delta.Y/6
Root.CFrame = Root.CFrame * CFrame.Angles(0, -math.rad(input.Delta.X)/2, 0)
end
end)
RunService.RenderStepped:Connect(function()
CurrentCamera.CFrame = Root.CFrame * CFrame.new(X_OFFSET, Y_OFFSET, Z_OFFSET) * CFrame.Angles(math.rad(Tilt), 0 , 0)
end)
However, Iām struggling to figure out how to make the camera pivot relative to the humanoid root part from the tilt value. Any help is appreciated.