Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I die when i switch weapons, how can i fix it?

I use three of TurboFusion's weapons. I can equip a weapon, but when i switch to another one I die. The weapons was fine before. The problem only happends on the weapons. Does anyone know how to fix this?

1 comment

0

Same, i just disabled the filter and nothing happens. I have no idea what to do with the clientmain.

1 answer

✓ Accepted answer

This happen to me before.

If you have FilteringEnabled on, it will kill you when you unequip. To turn it off, click Workspace in studio and uncheck FilteringEnabled.

If you want FilteringEnabled on, you have to go in the gun's script named, "clientMain", and replace the onUnequipped function with this:(hold CTRL+F when your in the script and type: function onUnequipped, then replace it with the code below)

function onUnequipped(deleteTool)
	if Selected then
		Selected = false
		
		breakReload = true
		
		--------------------[ RUNNING PLUGINS ]---------------------------------------
		
		for _, Plugin in pairs(Plugins.OnUnEquipped) do
			spawn(function()
				Plugin()
			end)
		end
		
		--------------------[ MODIFYING THE PLAYER ]----------------------------------
		
		Cam.FieldOfView = 70
		Cam.CameraType = Enum.CameraType.Custom
		
		UIS.MouseBehavior = Enum.MouseBehavior.Default
		UIS.MouseIconEnabled = true
		
		Player.CameraMode = Enum.CameraMode.Classic
		
		if armTable then
			armTable[1].Model:Destroy()
			armTable[2].Model:Destroy()
		elseif armModel then
			armModel:Destroy()
		end
		
		LLegWeld:Destroy()
		RLegWeld:Destroy()
		
		changePlayerTrans(Char, 0)
		
		mainGUI.Parent = script
		
		Shoulders.Right.Part1 = RArm
		Shoulders.Left.Part1 = LArm
		
		Humanoid.WalkSpeed = 16
		Humanoid.AutoRotate = true
		
		--------------------[ RESETING THE TOOL ]-------------------------------------
		
		gunIgnore:Destroy()
		
		mouseSensitivity = S.sensitivitySettings.Default
		
		MB1Down = false
		
		playerMass = 0
		
		Aimed = false
		
		camOffsets = {
			guiScope = {
				Rot = V3();
			};
			Reload = {
				Rot = V3();
				Code = nil;
			};
			Recoil = {
				Rot = V3();
				Code = nil;
			};
		}
		
		recoilAnim = {
			Pos = V3();
			Rot = V3();
			Code = nil;
		}

		--Setting the aim variables to unaimed
		spreadZoom = "unAimed"
		scopeMain.Visible = false
		scopeSteady.Visible = false
		aimAlpha = 0
		aimHeadOffset = 0
		jumpAnimMultiplier = 1
		translationDivisor = 7
		rotationMultiplier = S.momentumSettings.Amplitude.unAimed
		armTiltMultiplier = 1
		Scope.BackgroundTransparency = 1
		if S.guiScope then
			spawn(function()
				for _, Obj in pairs(Gun:GetChildren()) do
					if Obj:IsA("BasePart") then
						Obj.LocalTransparencyModifier = 0
					end
				end
			end)
		end
		
		onGround = true
		
		for _, Tab in pairs(gunParts) do
			Tab.Weld:Destroy()
			Tab.Weld = nil
		end
		
		for _,c in pairs(Connections) do
			c:disconnect()
		end
		
		Connections = {}
		
		if deleteTool then
			Cam:ClearAllChildren()
			Gun:Destroy()
		end
		
		wait() --This is here in case you dolphin dived and deselected the tool instantly
		
		if S.stanceSettings.standOnDeselect and Stance ~= 0 then
			crawlCamRot = 0
			isCrawling = false
			stanceSway = 1
			spreadStance = "Stand"
			Stand(true)
		end
		baseSpread = S.spreadSettings[spreadZoom][spreadStance][spreadMotion]
	end
end

2 comments

0

I die when i switch weapons, how can i fix it?

0

it hapen onley in the game in the roblox sudio it not hapen how can i fix it whte to do i tried to enable but it didnt work

This discussion is preserved as it was. New answers, comments, and votes are closed.