Putting a tool onto an NPC hands?

Is that NPC being cloned from the client, as well as those welds being put in by the client?

Mentioned a couple times throughout the thread that this has to be all done by the client. The server can not see the NPC, nor the weapon.

Yes, it’s being done through the client. I’m welding the tool to the hand, using Humanoid:EquipTool() and then playing the Roblox default R15Tool hold animation. Playing the animation manually is necessary.

Code:

humanoid:EquipTool(weaponClone)		

local weld = Instance.new('Weld')
if not weld then return end

weld.Part0 = armourClone.RightHand
weld.Part1 = weaponClone.Handle

weld.Parent = armourClone.RightHand

Result
image

Another problem with using Roblox’s default equip animation, is it cancels my own animation (I have a preset animation for the NPC)

The NPC shouldn’t be standing still. They have an Idle animation, which makes them look alive. The point is to try and equip the weapon while they have their idle animation running.

Yeah, unfortunately you have to orientate the sword too otherwise it looks like that. If you have your own animation that is fine. Since you just want it for cosmetic use, I think I may have another solution, let me get back to you in a few minutes.

Edit: Why does this have to be absolutely done client side? I’ve found the perfect solution but it involves the server handling it.

It’s not really an equip animation as well. The animation is literally just the default idle animation for R15 characters, so if you basically equip a sword as R15 with no animation bundle equipped, and just stand there on the spot without moving, that’s how I want the NPC to look.

Ik it’s def do-able and easy from the server. Client side reasoning though:

I see. Well I have tried multiple things to do it client side, all of them do not work. If you’re curious this is simply what I did serverside:


local armourClone = game.ReplicatedStorage:FindFirstChild('Dummy'):Clone()
local weaponClone = game.ReplicatedStorage:FindFirstChild('Sword'):Clone()

weaponClone.Parent = armourClone
armourClone.Parent = game.Workspace

local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/Asset?ID=507768375" 
animTrack = armourClone.Humanoid:LoadAnimation(animation)  

delay(0.15, function()
	animTrack:Play()
end)

The only solution I can personally think of is to go through and create a custom rig in the pose you want for each different tool, or use an image. I know Apocalypse Rising 2 does what you’re looking for, but I have no idea how they handle it unfortunately.

Yea that’s actually a good example of yea what I want :confused: it’s all good, thanks for the help :+1: I’ll have to keep looking around

1 Like

Ok so we are going to make an exact weld onto your R15 rig. Make sure it has the RightGripAttachment.

Anyway

Weld=Instance.new("Weld")
Weld.C0=armourClone.RightHand.RightGripAttachment.CFrame
Weld.C1=CFrame.new(weaponClone.GripPos.x, weaponClone.GripPos.y, weaponClone.GripPos.z,
	weaponClone.GripRight.x, weaponClone.GripUp.x, -weaponClone.GripForward.x,
	weaponClone.GripRight.y, weaponClone.GripUp.y, -weaponClone.GripForward.y,
	weaponClone.GripRight.z, weaponClone.GripUp.z, -weaponClone.GripForward.z)
Weld.Part0=armourClone.RightHand
Weld.Part1=weaponClone.Handle
12 Likes

Wouldn’t the Part0 be the Handle, not the RightHand?

1 Like

Looking at how the RightGrip weld behaves when you equip a tool, this is the correct way around.

1 Like

Didn’t do anything :confused:

local Weld=Instance.new("Weld")
Weld.C0=armourClone.RightHand.RightGripAttachment.CFrame
Weld.C1=CFrame.new(weaponClone.GripPos.x, weaponClone.GripPos.y, weaponClone.GripPos.z,
	weaponClone.GripRight.x, weaponClone.GripUp.x, -weaponClone.GripForward.x,
	weaponClone.GripRight.y, weaponClone.GripUp.y, -weaponClone.GripForward.y,
	weaponClone.GripRight.z, weaponClone.GripUp.z, -weaponClone.GripForward.z)
Weld.Part0=armourClone.RightHand
Weld.Part1=weaponClone.Handle	

weaponClone.Parent = armourClone
armourClone.Parent = workspace

EDIT I GOT IT TO WORK! :smiley: You were just missing this:

Weld.Parent = weaponClone.Handle

2 Likes

You can use

Weld.C1 = weaponClone.Grip

instead of that huge cframe constructor

12 Likes

Here is what the final product looks like :smiley: :smiley:

11 Likes

I hate to bump such an old post, but hopefully I can save someone a few hours of their life trying to figure this out as I did. Here is some useful information for anyone who is…

1. Attempting to equip a tool to an NPC (non-player character)
2. Attempting to do this on the CLIENT
3. Using an R6 rig

The orientation of an R6’s RightGripAttachment is -90 degress off in the X direction when compared to an R15, so you will need to account for this when creating the weld. It appears the server already accounts for this and fixes it automatically when using humanoid:EquipTool(…) hence why this is only an issue on the client.

-- Adjust the attachment of the R6 rig to be orientated correctly for the tool
local bodyPart = newAnimatedViewport.originalRig["Right Arm"]
bodyPart.RightGripAttachment.CFrame *= CFrame.Angles(-90, 0, 0)

-- Create the weld/motor6D, I use a Motor6D because I animate the tool
local motor = Instance.new("Motor6D")
motor.Name = "RightGrip"
motor.C0 = bodyPart.RightGripAttachment.CFrame
motor.C1 = mainWeaponAsset.Grip
motor.Part0 = bodyPart
motor.Part1 = mainWeaponAsset.Handle
motor.Parent = bodyPart

-- Parent the tool to the R6 rig
mainWeaponAsset.Parent = newAnimatedViewport.originalRig

What it looks like if you do not account for this:

image

What it should look like:

Correct orientation

4 Likes