Motor6D with Spring help

  1. Something like this?

  2. For some reason the weapon spins uncontrollably

  3. Ive tried tampering with it but just gets more annoying.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local SwingRemote = game.ReplicatedStorage.GameMechanics.Remotes.Swing
local ToolModelsFolder = game.ReplicatedStorage.GameMechanics.ToolModels
local Spring = require(game.ReplicatedStorage.GameMechanics.Modules.Spring)

SwingRemote.OnServerEvent:Connect(function(player, delete, toolname)
	local tool = ToolModelsFolder:FindFirstChild(toolname)
	if delete == false then
		for i,v in pairs(game.ReplicatedStorage.GameMechanics.ToolModels:GetDescendants()) do
			if v.Name == tool.Name then
				local cloned = tool:Clone()
				local model = cloned
				local main = model:FindFirstChild("AttachmentPart")
				cloned.Parent = player.Character:FindFirstChild("UpperTorso")
				for _, child in ipairs(model:GetChildren()) do
					if child:IsA("BasePart") then
						if child ~= main then
							local weld = Instance.new("WeldConstraint")
							weld.Part0 = main
							weld.Part1 = child
							weld.Parent = child
						end
					end
					if child:IsA("MeshPart") then
						if child ~= main then
							local weld = Instance.new("WeldConstraint")
							weld.Part0 = main
							weld.Part1 = child
							weld.Parent = child
						end
					end
				end
				print(cloned.Parent)
				local motor6d = Instance.new("Motor6D")
				motor6d.Parent = cloned:FindFirstChild("AttachmentPart")
				motor6d.Part0 = player.Character:FindFirstChild("UpperTorso")
				motor6d.Part1 = cloned:FindFirstChild("AttachmentPart")
				task.wait(0.01)
				local weaponSway = Spring.new()
				weaponSway.Damper = 0.8 --// Modify (lower value = more springy)
				weaponSway.Speed = 8 --// Modify (higher value = spring will reach target in less time
				local Weapon = cloned -- WeaponModel
				local WeaponModel = cloned --WeaponMeshPart
				local Camera = workspace.CurrentCamera
				local lastCameraRotation = 0
				game:GetService("RunService").Heartbeat:Connect(function(delta)
					local _, yRotation, _ = Camera.CFrame:ToOrientation()

					weaponSway:Impulse((yRotation - lastCameraRotation) * delta * 10)

					motor6d.C0 *= CFrame.Angles(0, 0, weaponSway.Position)
				end)
			end
		end
	end
end)

SwingRemote.OnServerEvent:Connect(function(player, delete, toolname) -- delete part
	if delete == true then
	task.wait(0.1)
	local tool = player.Character.UpperTorso:FindFirstChild(toolname)
	tool:Destroy()		
	end
end)

Here is the place file,
TestSwing.rbxl (92.8 KB)