Roblox has their own weapons kit as you can see here
but that kit is way too inefficient, it lags and consumes a lot of script activity so I made my own system but I want to keep roblox’s shoulder camera script
I’ve messed about the script but I couldnt figure out how to take just the camera script and use it on my own weapons system
has anyone tried doing the same? does anyone know a way to do that?
I’ve looked over the model. The module ShoulderCamera is a bit lengthy but if you understand it just a little you should be able to use it Look within the WeaponSystem module find ( Cntrl + F ) any Camera related lines of code and just try to understand what the ShoulderCamera is doing on those lines.
Within WeaponSystem Module
Inside the .setup() function of the module, there’s a conditional if IsServer then module is setup server-side and client-side within the client the setup sets up the ShoulderaCamera Aspect of the weapon system as you can see below. I’m just pointing this out so you try to analyze it yourself further through testing
WeaponsSystem.camera = ShoulderCamera.new(WeaponsSystem)
WeaponsSystem.gui = WeaponsGui.new(WeaponsSystem)
if ConfigurationValues.SprintEnabled.Value then
WeaponsSystem.camera:setSprintEnabled(ConfigurationValues.SprintEnabled.Value)
end
if ConfigurationValues.SlowZoomWalkEnabled.Value then
WeaponsSystem.camera:setSlowZoomWalkEnabled(ConfigurationValues.SlowZoomWalkEnabled.Value)
end
Also a function within WeaponSystem Module .setWeaponEquipped() I would say this is to toggle camera when tool/weapon is equipped but i tested and its just toggled on regardless it seems.
if WeaponsSystem.camera then
WeaponsSystem.camera:resetZoomFactor()
WeaponsSystem.camera:setHasScope(false)
if WeaponsSystem.currentWeapon then
WeaponsSystem.camera:setZoomFactor(WeaponsSystem.currentWeapon:getConfigValue("ZoomFactor", 1.1))
WeaponsSystem.camera:setHasScope(WeaponsSystem.currentWeapon:getConfigValue("HasScope", false))
end
end
–
ALSO when you see things like WeaponsSystem.camera: Its actually methods/functions developed within the ShoulderCamera Module Like this…
function ShoulderCamera:setHasScope(hasScope)
if self.hasScope == hasScope then
return
end
self.hasScope = hasScope
self:updateZoomState()
end
Final Note: To use ShoulderCamera you will need to use module to fully utilize its features/methods
function ShoulderCamera.new(weaponsSystem) -- // Very important line
return self -- You also need to understand what last line on of this function is doing
I’ve pasted some important lines where the ShoulderCamera Module is used. Like i said before the ShoulderCamera Module is a bit lengthy I wouldn’t recommend trying to use this systemif you don’t have enough experience with code utilizing Metamethods and self