Dragging npc system problem

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? cool dragging system like in hitman games

  2. What is the issue? the whole body gets dragged instead of just the arm, also the npcs arm ends up inside the player’s character

  3. What solutions have you tried so far? i added a part and welded to both player’s char and npc’s arm, i also rotated it a bunch of times, thought it might work :grin:

script:

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local mos = plr:GetMouse()
local uis = game:GetService("UserInputService")
local text = script.Parent:WaitForChild("First")
local hrp = char:WaitForChild("HumanoidRootPart")


uis.InputChanged:Connect(function(input)
	if mos.Target then

		if mos.Target:FindFirstChild("Type") and mos.Target:FindFirstChildWhichIsA("StringValue") then
			local typez = mos.Target:FindFirstChild("Type")


			local distance = (mos.Target.Position - hrp.Position).Magnitude

			local maxdis = 5

			if typez.Value == "NPC" then
				if distance < maxdis then
					text.Visible = true
					local npc = mos.Target.Parent
					local hum = npc:FindFirstChildWhichIsA("Humanoid")
					local npchnd = npc:WaitForChild("Handle")
					local plrhnd = char:WaitForChild("Right Arm")

					local animatescript = char:WaitForChild("Animate")
					local walk = animatescript:WaitForChild("walk"):WaitForChild("WalkAnim")
					local idle = animatescript:WaitForChild("idle")

					uis.InputBegan:Connect(function(input)
						local dragging = false
						if input.KeyCode == Enum.KeyCode.E and hum.Health == 0 and dragging == false then
							dragging = true
							walk.AnimationId = "rbxassetid://17564614141"
							idle.Animation1.AnimationId = "rbxassetid://17565414366"
							idle.Animation2.AnimationId = "rbxassetid://17565414366"
							local weld = Instance.new("Motor6D")
							weld.Name = "carryweld"
							weld.Part0 = char.Handle
							weld.Part1 = npc.Handle
							weld.Parent = char

							weld.C0 = CFrame.new(0, 0, 0) * CFrame.Angles(0, 0, 0)
							local function updateWeld()
								local playerPos = hrp.Position
								local npcHandPos = npchnd.Position
								local direction = (playerPos - npcHandPos).unit
								weld.C0 = CFrame.new(direction * 2, 0, 0) * CFrame.Angles(0, 0, 0)
							end
							game:GetService("RunService").RenderStepped:Connect(updateWeld)
							
							for _, v in pairs(npc:GetChildren()) do
								if v:IsA("BasePart") then
									v.Massless = true
								end
							end
						elseif input.KeyCode == Enum.KeyCode.E and dragging == true then
							walk.AnimationId = "rbxassetid://17564598792"
							idle.Animation1.AnimationId = "rbxassetid://13577195313"
							idle.Animation2.AnimationId = "rbxassetid://13577195313"
							char:FindFirstChildWhichIsA("Motor6D"):Destroy()
						end
					end)
				else
					text.Visible = false
				end
			end
		end
	end
end)

this is my first time playing around with motor 6d lulz so idrk what to do

1 Like