Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How Can I Change This Gun Camera View From Behind The Character, To A First Person View?

Asked by 3 years ago

I've Attempted To Fix This Script Myself, But Whatever I Do Basically Breaks This Tool. Most Of What I Am Trying To Fix Is Right Here.

self.fieldOfView = 70
    self.minPitch = math.rad(-75) -- min degrees camera can angle down
    self.maxPitch = math.rad(75) -- max degrees camera can cangle up
    self.normalOffset = Vector3.new(2.25, 2.25, 10.5) -- this is the camera's offset from the player
    self.zoomedOffsetDistance = 8 -- number of studs to zoom in from default offset when zooming
    self.normalCrosshairScale = 1
    self.zoomedCrosshairScale = 0.75
    self.defaultZoomFactor = 1
    self.canZoom = true

This Is The Rest.

-- Configuration parameters (constants)
    self.fieldOfView = 70
    self.minPitch = math.rad(-75) -- min degrees camera can angle down
    self.maxPitch = math.rad(75) -- max degrees camera can cangle up
    self.normalOffset = Vector3.new(2.25, 2.25, 10.5) -- this is the camera's offset from the player
    self.zoomedOffsetDistance = 8 -- number of studs to zoom in from default offset when zooming
    self.normalCrosshairScale = 1
    self.zoomedCrosshairScale = 0.75
    self.defaultZoomFactor = 1
    self.canZoom = true
    self.zoomInputs = { Enum.UserInputType.MouseButton2, Enum.KeyCode.ButtonL2 }
    self.sprintInputs = { Enum.KeyCode.LeftShift }
    self.mouseRadsPerPixel = Vector2.new(1 / 480, 1 / 480)
    self.zoomedMouseRadsPerPixel = Vector2.new(1 / 1200, 1 / 1200)
    self.touchSensitivity = Vector2.new(1 / 100, 1 / 100)
    self.zoomedTouchSensitivity = Vector2.new(1 / 200, 1 / 200)
    self.touchDelayTime = 0.25 -- max time for a touch to count as a tap (to shoot the weapon instead of control camera),
                               -- also the amount of time players have to start a second touch after releasing the first time to trigger automatic fire
    self.recoilDecay = 2 -- higher number means faster recoil decay rate
    self.rotateCharacterWithCamera = true
    self.gamepadSensitivityModifier = Vector2.new(0.85, 0.65)
    -- Walk speeds
    self.zoomWalkSpeed = 8
    self.normalWalkSpeed = 16
    self.sprintingWalkSpeed = 24

    -- Current state
    self.enabled = false
    self.yaw = 0
    self.pitch = 0
    self.currentCFrame = CFrame.new()
    self.currentOffset = self.normalOffset
    self.currentRecoil = Vector2.new(0, 0)
    self.currentMouseRadsPerPixel = self.mouseRadsPerPixel
    self.currentTouchSensitivity = self.touchSensitivity
    self.mouseLocked = true
    self.touchPanAccumulator = Vector2.new(0, 0) -- used for touch devices, represents amount the player has dragged their finger since starting a touch
    self.currentTool = nil
    self.sprintingInputActivated = false
    self.desiredWalkSpeed = self.normalWalkSpeed
    self.sprintEnabled = false -- true means player will move faster while doing sprint inputs
    self.slowZoomWalkEnabled = false -- true means player will move slower while doing zoom inputs
    self.desiredFieldOfView = self.fieldOfView

1 answer

Log in to vote
1
Answered by
haba_nero 386 Moderation Voter
3 years ago

Change normalOffset to (0,0,0) and get a first-person lock script. Also, make sure to make the entire character locally transparent so you can't see your own body ;)

Or maybe just use another gun model. The Roblox endorsed ones are kind of bad lol. I use a pistol model as a starter kit and make them into other guns!

0
Thanks For The Help! I'm Not That Good At Scripting, So It Would Be Extremely Hard To Use Your Method With The Pistol Model, But Thanks For The Advice! ricelicker 52 — 3y
Ad

Answer this question