Roblox Weapons Kit Help

Does anyone have an idea on how to disable the permanent shoulder camera on the basic Roblox weapons kit? This one: here

I want to make it so that the camera is only locked when the weapon is equipped.

2 Likes

There’s only two modules you’ll need to edit here. WeaponsSystem and BulletWeapon

In the WeaponsSystem module, look for this code and remove it:

WeaponsSystem.camera:setEnabled(true)

In the BulletWeapon module, go to the BulletWeapon:onEquippedChanged() function and replace it with this code:

function BulletWeapon:onEquippedChanged()
	BaseWeapon.onEquippedChanged(self)

	if not IsServer then
		if self.weaponsSystem.camera then
			if self.equipped then
				self.startupFinished = false
			end
		end

		if self.equipped then
			self.weaponsSystem.camera:setEnabled(true)
			ContextActionService:BindAction("ReloadWeapon", function(...) self:onReloadAction(...) end, false, Enum.KeyCode.R, Enum.KeyCode.ButtonX)
		else
			self.weaponsSystem.camera:setEnabled(false)
			ContextActionService:UnbindAction("ReloadWeapon")

			-- Stop charging/discharging sounds
			local chargingSound = self:getSound("Charging")
			local dischargingSound = self:getSound("Discharging")
			if chargingSound and chargingSound.Playing then
				chargingSound:Stop()
			end
			if dischargingSound and dischargingSound.Playing then
				dischargingSound:Stop()
			end
		end

		self.triggerDisconnected = false
	end
end

Hopefully this helps!

2 Likes

Thanks so much! Also, would there be a way to make sure that the weapon can not damage the same team?

Oh, I forgot, I’ll also mark your reply as a solution since that was the main thing I was asking.

Not sure yet. I’ll experiment with the scripts and I’ll let you know if it works out!

Thank you so much! (30 c please come on)

Have you made any progress yet?

Sorry for the day late response. I’m still working on it, but I’ve found this:

function WeaponsSystem.getTeam(player)
	local handler = _getTeamCallback or _defaultGetTeamCallback
	return handler(player)
end

function WeaponsSystem.playersOnDifferentTeams(player1, player2)
	if player1 == player2 or player1 == nil or player2 == nil then
		-- This allows players to damage themselves and NPC's
		return true
	end

	local player1Team = WeaponsSystem.getTeam(player1)
	local player2Team = WeaponsSystem.getTeam(player2)
	return player1Team == 0 or player1Team ~= player2Team
end

It is being used within the code, but to no use. I’m going to be trying to fix this later today if I have the time.

Nice, thank you for the update!

Hello again! I’m glad to say I found a solution for the teams, and it was a pretty dumb fix too.

In the WeaponsSystem module, just edit the _defaultGetTeamCallback function:

local function _defaultGetTeamCallback(player)
	return player.Team
end

Before, it was like this:

local function _defaultGetTeamCallback(player)
	return 0
end

When it returned 0, it would not check what team both players were in. I’m guessing this was just in case you had no teams in your game. Anyway, hope this works out for you and let me know if you get any errors!

1 Like

It worked perfectly, thanks! Now the only thing I have to figure out is how to get the camera subject back to normal after the weapon is unequipped.

No problem! The camera subject is pretty annoying but I think you need to go in the ShoulderCamera module and edit the setEnabled function.