I'm trying to make a script that will grab an npc in which you can throw them afterwards.
if input.UserInputType == Enum.UserInputType.MouseButton2 and clicked then local welddb clicked = false if firstrc then firstrc = false GrabHitHandling = humanoid.Touched:Connect(function(hit, limb) if not isGrabbing then grabAnimate:Play() wait(.55) if limb.Name == "RightHand" or limb.Name == "RightUpperArm" or limb.Name == "RightLowerArm" then isGrabbing = true target = hit.Parent:FindFirstChild("Humanoid") if target then EntInv:InvokeServer(player, target) GrabbingVar:FireServer(isGrabbing) local d = target.Parent:GetDescendants() grabbedAnimate = target:LoadAnimation(grabbed) grabbedAnimate.Looped = false for i = 1, #d do local desc = d[i] if desc.Name == "Head" then if not character.RightHand:FindFirstChild("Weld") and not welddb then print("6") local weld = Instance.new("Weld") weld.Part0 = character.RightHand weld.Part1 = target.Parent.Head weld.Parent = character.RightHand welddb = true end end end if not grabbedAnimate.IsPlaying and not grabbingAnimate.IsPlaying then print("7") grabbedAnimate:Play() idleAnimate:Stop() grabbingAnimate:Play() print("7.5") end elseif not target and GrabHitHandling then GrabHitHandling:Disconnect() wait(4/5) clicked = true end end elseif limb.Name ~= "RightHand" or limb.Name ~= "RightUpperArm" or limb.Name ~= "RightLowerArm" and GrabHitHandling then GrabHitHandling:Disconnect() wait(4/5) clicked = true end end) elseif not firstrc and isGrabbing then print("8") local origmotorparent local socket local markerdb = true local throwBody = throwAnimate:GetMarkerReachedSignal("ThrowBody") throwAnimate:Play() print("9") local welddb = true if throwAnimate.IsPlaying and markerdb then print("10") local thrBody = throwBody:Connect(function() print("11") markerdb = false local d = target.Parent:GetDescendants() for i=1,#d do local desc = d[i] if desc:IsA("Motor6D") then print("12") -- should print 15 times origmotorparent = desc.Parent socket = Instance.new("BallSocketConstraint") local part0 = desc.Part0 local joint_name = desc.Name local attachment0 = desc.Parent:FindFirstChild(joint_name.."Attachment") or desc.Parent:FindFirstChild(joint_name.."RigAttachment") local attachment1 = part0:FindFirstChild(joint_name.."Attachment") or part0:FindFirstChild(joint_name.."RigAttachment") if attachment0 and attachment1 then socket.Attachment0, socket.Attachment1 = attachment0, attachment1 socket.Parent = desc.Parent desc.Parent = game.ServerStorage end end end if welddb then print("13") character.RightHand.Weld:Destroy() welddb = false end print("14") grabbingAnimate:Stop() grabbedAnimate:Stop() -- local bodythrust = Instance.new("BodyThrust") -- bodythrust.Force = Vector3.new(9999,9999,9999) -- bodythrust.Location = workspace.CurrentCamera.CFrame.lookVector -- bodythrust.Parent = target.Parent.UpperTorso -- wait(.4) -- bodythrust:Destroy() wait(3) print("15") for _, desc in pairs(game.ServerStorage:GetDescendants()) do if desc:IsA("Motor6D") then print("16") -- 15 times desc.Parent = origmotorparent socket:Destroy() end end isGrabbing = false firstrc = true clicked = true markerdb = true print("Throw/Grab loop done") end) if thrBody and firstrc == true then thrBody:Disconnect() end end end end
For some reason, past the
local thrBody = throwBody:Connect(function()
line, everything is printing for the number of times I have grabbed and thrown in that run. Any ideas?