Swing Tool help needed, physics are weird!

  1. I want to achieve something like this.
  2. The issue is the physics isnt doing what i want it to do
  3. Ive tried different settings to get it to work.
local SwingRemote = game.ReplicatedStorage.GameMechanics.Remotes.Swing
local ToolModelsFolder = game.ReplicatedStorage.GameMechanics.ToolModels

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 Attachment = Instance.new("Attachment")
				Attachment.Parent = player.Character:FindFirstChild("UpperTorso")
				Attachment.Name = "SwingAttach"
				Attachment.CFrame = CFrame.new(0.5, 0.5, 0.5)
				Attachment.CFrame = CFrame.new(-90, -90, 0)
				print(Attachment.Parent)
				local Attachment2 = Instance.new("Attachment")
				Attachment2.Parent = player.Character:FindFirstChild("UpperTorso")
				Attachment2.Name = "SwingAttach2"
				Attachment2.CFrame = CFrame.new(0.5, 0.5, 0.7)
				local cloned = tool:Clone()
				cloned.Parent = player.Character:FindFirstChild("UpperTorso")
				local parte = cloned:FindFirstChild("AttachmentPart")
				parte.Anchored = true
				print(cloned.Parent)
				local weld = Instance.new("CylindricalConstraint")
				weld.Parent = cloned:FindFirstChild("AttachmentPart")
				weld.LimitsEnabled = true
				weld.UpperLimit = 0.3
				weld.Attachment0 = Attachment
				weld.Attachment1 = Attachment2
				local model = cloned
				local main = model:FindFirstChild("AttachmentPart")

				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
			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)
	local swing = player.Character.UpperTorso.SwingAttach
	local swing2 = player.Character.UpperTorso.SwingAttach2
	tool:Destroy()	
	swing:Destroy()	
	swing2:Destroy()	
	end
end)

Server Script ^

local tool = script.Parent
local remote = game.ReplicatedStorage.GameMechanics.Remotes:FindFirstChild("Swing")
local delete = false

tool.Unequipped:Connect(function()
	if delete == false then
		local toolname = tool.Name
		remote:FireServer(delete, toolname)
		task.wait(0.1)
		delete = true
	end
end)

tool.Equipped:Connect(function()
	if delete == true then
		local toolname = tool.Name
		remote:FireServer(delete, toolname)
		task.wait(0.1)
		delete = false
	end
end)

Client Script/ Handler ^
Other stuff
image
image

yo, i’ll recommend you using characters humanoidrootpart velocity with spring, and weld the weapon with motor6d so you multiply the original C0 with the spring position, this is what i use


changed server script and tested it on a dummy.

local SwingRemote = game.ReplicatedStorage.GameMechanics.Remotes.Swing
local ToolModelsFolder = game.ReplicatedStorage.GameMechanics.ToolModels

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()
				cloned.Parent = player.Character:FindFirstChild("UpperTorso")
				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)
				motor6d.C0 = CFrame.new(1.3, 0.7, 1.5)
				local model = cloned
				local main = model:FindFirstChild("AttachmentPart")

				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
			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)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.