Check my original post "How Do I Change The Shoulder Camera Scripts In The "Auto Rifle" Model By Roblox To Change Plr Camera?" and check my second post "How Do I Change The Shoulder Camera Scripts In The "Auto Rifle" Model By Roblox Continuation? and check my third post "How Do I Change The Shoulder Camera Scripts In The "Auto Rifle" Model By Roblox Continuation 2?" (I'm sorry for how long these series of questions are, please answer if you can.)
--Continuation
function ShoulderCamera:handleTouchToolFiring()
if self.touchObj then
if self.lastTapEndTime then -- and not (self.zoomState and self.hasScope) then
local touchTime = tick() - self.lastTapEndTime
if touchTime < self.touchDelayTime and self.currentTool and self.touchPanAccumulator.Magnitude < 0.5 and not self.firingTool and not self.applyingTouchPan then
self.firingTool = true
self.currentTool:Activate()
end
end
else
if self.currentTool and self.firingTool then
self.currentTool:Deactivate()
end
self.firingTool = false
end
end
function ShoulderCamera:isTouchPositionForCamera(pos)
if LocalPlayer then
local guiObjects = LocalPlayer.PlayerGui:GetGuiObjectsAtPosition(pos.X, pos.Y)
for _, guiObject in ipairs(guiObjects) do
if guiObject.Name == "DynamicThumbstickFrame" then
return false
end
end
return true
end
return false
end
function ShoulderCamera:onInputBegan(inputObj, wasProcessed)
if self.touchObj then
self.touchObj = nil
wasProcessed = false
end
if inputObj.KeyCode == Enum.KeyCode.Thumbstick2 then
self.gamepadPan = Vector2.new(inputObj.Position.X, inputObj.Position.Y)
elseif inputObj.KeyCode == Enum.KeyCode.Thumbstick1 then
self.movementPan = Vector2.new(inputObj.Position.X, inputObj.Position.Y)
elseif inputObj.UserInputType == Enum.UserInputType.Touch then
local touchStartPos = Vector2.new(inputObj.Position.X, inputObj.Position.Y)
if not wasProcessed and self:isTouchPositionForCamera(touchStartPos) and not self.touchObj then
self.touchObj = inputObj
self.touchStartTime = tick()
self.eventConnections.touchChanged = inputObj.Changed:Connect(function(prop)
if prop == "Position" then
local touchTime = tick() - self.touchStartTime
local newTouchPos = Vector2.new(inputObj.Position.X, inputObj.Position.Y)
local delta = (newTouchPos - touchStartPos) * self.currentTouchSensitivity
local yawInput = -delta.X
local pitchInput = -delta.Y
if self.touchPanAccumulator.Magnitude > 0.01 and touchTime > self.touchDelayTime then
if not self.applyingTouchPan then
self.applyingTouchPan = true
self.touchPanAccumulator = Vector2.new(0, 0)
end
end
self:applyInput(yawInput, pitchInput)
self.touchPanAccumulator = self.touchPanAccumulator + Vector2.new(yawInput, pitchInput)
touchStartPos = newTouchPos
end
end)
end
end
end
function ShoulderCamera:onInputChanged(inputObj, wasProcessed)
if inputObj.UserInputType == Enum.UserInputType.MouseMovement then
local yawInput = -inputObj.Delta.X * self.currentMouseRadsPerPixel.X
local pitchInput = -inputObj.Delta.Y * self.currentMouseRadsPerPixel.Y
self:applyInput(yawInput, pitchInput)
elseif inputObj.KeyCode == Enum.KeyCode.Thumbstick2 then
self.gamepadPan = Vector2.new(inputObj.Position.X, inputObj.Position.Y)
elseif inputObj.KeyCode == Enum.KeyCode.Thumbstick1 then
self.movementPan = Vector2.new(inputObj.Position.X, inputObj.Position.Y)
end
end
function ShoulderCamera:onInputEnded(inputObj, wasProcessed)
if inputObj.KeyCode == Enum.KeyCode.Thumbstick2 then
self.gamepadPan = Vector2.new(0, 0)
elseif inputObj.KeyCode == Enum.KeyCode.Thumbstick1 then
self.movementPan = Vector2.new(0, 0)
elseif inputObj.UserInputType == Enum.UserInputType.Touch then
if self.touchObj == inputObj then
if self.eventConnections and self.eventConnections.touchChanged then
self.eventConnections.touchChanged:Disconnect()
self.eventConnections.touchChanged = nil
end
local touchTime = tick() - self.touchStartTime
if self.currentTool and self.firingTool then
self.currentTool:Deactivate()
elseif self.zoomState and self.hasScope and touchTime < self.touchDelayTime and not self.applyingTouchPan then
self.currentTool:Activate() -- this makes sure to shoot the sniper with a single tap when it is zoomed in
self.currentTool:Deactivate()
end
self.firingTool = false
self.touchPanAccumulator = Vector2.new(0, 0)
if touchTime < self.touchDelayTime and not self.applyingTouchPan then
self.lastTapEndTime = tick()
else
self.lastTapEndTime = nil
end
self.applyingTouchPan = false
self.gamepadPan = Vector2.new(0, 0)
self.touchObj = nil
end
end
end
return ShoulderCamera
