This particular section of the script messes up the camera, for instance...
if you change
Camera.CameraType = "Scriptable"
to fixed, it'll turn but it'll glitch the character... Any solution?
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter
Camera.CameraType = "Scriptable"
UserInputService.InputChanged:connect(function(inputObject)
local inputObject = inputObject
if inputObject.UserInputType == Enum.UserInputType.MouseMovement then
local XChange, YChange = inputObject.Delta.X, inputObject.Delta.Y
if _G.Zoomed == true then
xangle = xangle + YChange*0.005*_G.MouseSensitivity
yangle = yangle + XChange*0.005*_G.MouseSensitivity
else
xangle = xangle + YChange*0.005
yangle = yangle + XChange*0.005
end
newxangle = xangle
if -xangle+_G.RecoilX > math.rad(89) then
xangle = -math.rad(89)
_G.RecoilX = 0
Camera.CoordinateFrame = CFrame.new(_G.Target.Position) --Start at the position of the part
* CFrame.Angles(0, -yangle+_G.RecoilY, 0) --Rotate by the angle
* CFrame.new(0, 0, 0) *CFrame.Angles(-xangle,0,0)
elseif -xangle+_G.RecoilX < -math.rad(89) then
xangle = math.rad(89)
_G.RecoilX = 0
Camera.CoordinateFrame = CFrame.new(_G.Target.Position) --Start at the position of the part
* CFrame.Angles(0, -yangle+_G.RecoilY, 0) --Rotate by the angle
* CFrame.new(0, 0, 0) *CFrame.Angles(-xangle,0,0)
else
Camera.CoordinateFrame = CFrame.new(_G.Target.Position) --Start at the position of the part
* CFrame.Angles(0, -yangle+_G.RecoilY, 0) --Rotate by the angle
* CFrame.new(0, 0, 0) *CFrame.Angles(-xangle+_G.RecoilX,0,0)
end
local MDir = Camera.CoordinateFrame.lookVector--mouse.UnitRay.Direction.unit
local RotTarget = Vector3.new(MDir.x,0,MDir.z)
local cfYaw = CFrame.new(myChar.HumanoidRootPart.Position,myChar.HumanoidRootPart.Position + RotTarget)
myChar.HumanoidRootPart.CFrame = cfYaw
end
end)
RenderStepped:connect(function()
if -xangle+_G.RecoilX > math.rad(89) then
xangle = -math.rad(89)
_G.RecoilX = 0
Camera.CoordinateFrame = CFrame.new(_G.Target.Position) --Start at the position of the part
* CFrame.Angles(0, -yangle+_G.RecoilY, 0) --Rotate by the angle
* CFrame.new(0, 0, 0) *CFrame.Angles(-xangle,0,0)
elseif -xangle+_G.RecoilX < -math.rad(89) then
xangle = math.rad(89)
_G.RecoilX = 0
Camera.CoordinateFrame = CFrame.new(_G.Target.Position) --Start at the position of the part
* CFrame.Angles(0, -yangle+_G.RecoilY, 0) --Rotate by the angle
* CFrame.new(0, 0, 0) *CFrame.Angles(-xangle,0,0)
else
Camera.CoordinateFrame = CFrame.new(_G.Target.Position) --Start at the position of the part
* CFrame.Angles(0, -yangle+_G.RecoilY, 0) --Rotate by the angle
* CFrame.new(0, 0, 0) *CFrame.Angles(-xangle+_G.RecoilX,0,0)
end
local MDir = Camera.CoordinateFrame.lookVector--mouse.UnitRay.Direction.unit
local RotTarget = Vector3.new(MDir.x,0,MDir.z)
local cfYaw = CFrame.new(myChar.HumanoidRootPart.Position,myChar.HumanoidRootPart.Position + RotTarget)
myChar.HumanoidRootPart.CFrame = cfYaw
end)
