As you can see, I have my NPC, and the selection box is large because there is a weapon being put inside the model as well. What I am trying to achieve is the weapon being ‘equipped’ to the NPC’s hand. I can’t just position the weapon in workspace, then move it to RepStorage, as even tho that would clone to near the NPC, the NPC has an animation with their character, so they wouldn’t actually be holding the weapon.
Would any of the tools Properties be used to maybe like weld it to the NPCs arms. Specifically looking at the Grip ones. Basically need to have it welded to the arm, so it follows with the NPC’s animation.
EDIT This is all being done via the Client!! This is because the classes are only visible to the client, depending on which class they have selected in this menu! So it has to all be done via the client. I’ve tried doing it via the server and doing crazy deleting and repositioning to hide it from other players, but it’s just way to convaluted and didn’t end up working in the end.
So client only. Ik EquipTool does not work in the client, that’s why I’m trying to figure out how to manually equip a tool using the tools grips or something, idk
Heard of Moon Animation Suite plugin? You can make your tool and weld it to any part of the body you want. It has also animation categories. Search on YouTube Moon Animation Suite Tutorial. That should help.
Hmm ok. Only thing is that there are a number of different NPC’s that all run the same animation, but have different weapons. So I was hoping to use the tools GripPos to somehow weld it to the NPC’s arm (like how the normal player with the sword equipped would hold it)
EDIT Thought maybe using humanoid:EquipTool() would work with NPC humanoids, but that don’t seem to work
function loadIdleAnimation(humanoid)
local animation = script['Idle']
if not animation then return end
local animTrack = humanoid:LoadAnimation(animation)
if not animTrack then return end
animTrack.Looped = true
animTrack:Play()
end
function getModel:Class(selected)
local classFolder = classes:FindFirstChild(selected)
if not classFolder then return end
local armour = classFolder:FindFirstChild('Armour')
if not armour then return end
local weapon = classFolder:FindFirstChild('Weapon')
if not weapon then return end
local armourClone = armour:Clone()
armourClone.Name = 'ArmourClone'
local weaponClone = weapon:Clone()
weaponClone.Name = 'WeaponClone'
if workspace:FindFirstChild('ArmourClone') then
workspace.ArmourClone:Destroy()
end
local character = armourClone
local humanoid = character.Humanoid
weaponClone.Parent = armourClone
armourClone.Parent = workspace
humanoid:EquipTool(weaponClone)
loadIdleAnimation(humanoid)
end
Code if anyone wants to have a look. The weapon has to work with this preset animation
Not really sure how to get the rotations, etc. working
Maybe using the animations from within the weapon might help
EDIT Although, certain tools (like the sword) don’t use an Idle animation with their tool. They just use the players standard idle animation and the tools GripPos into the players hand So need to find a way for the sword (and any weapon that does not have an idle animation) to be gripped properly. Then weapons that do contains a preset idle animation (like the bow) can use their own idle animations?
That would be easier to do with Moon Animation Suite. I mean you can place your tool however you want and animate with it, but you are trying to use script. Maybe you should make your animations inside the script and that script should be inside of tool? Not really sure.
The reason this works is because the Grip properties are really just a CFrame split into it’s 4 parts.
p (GripPos),
lookVector (GripFront),
rightVector (GripRight), and
upVector (GripUp)
There is no valid constructor for CFrame with four vectors. You will have to use CFrame.new where you individually feed all 16 components of the vectors combined. See the CFrame page on the Developer Hub for an overview of which component goes where in the matrix:
If you are still using regular ROBLOX Tool objects (with a handle in them), the Grip properties allow you to specify how the tool needs to be held. Specifically, Grip allows you to set how the tool is held with one positional and rotational CFrame.
This does require some trial and error if you can not immediately tell what is wrong with your grip.
Additionally, the most common issue with “NPC tools” is the fact that LocalScripts do not work inside NPCs. You may need to consider this, I do not know your current model structure.
You do not need manual welds nor animations for just holding stuff. Simply putting a Tool object with a BasePart named Handle inside a character will always make it start wielding the tool.
To make sure it is held the correct way, you can set the tool’s Grip before you parent it - either by creating a new Tool object and setting the Grip, or having a pre-made working Tool and simply reparenting/cloning it when it is needed.
Either way (in a Script or in your Command Line to do it in Studio), this is what you want to use:
tool.Grip = CFrame.new()
The supplied CFrame position and rotation will be used to weld the Handle to the hand.
Well I mean here’s a few problems with what I’ve tried so far and what you’ve listed:
Using like EquipTool() does not automatically equip it to the NPC character. I had to create a weld in a script to get it to actual appear even near the character (this did not equip the tool however)
The tools I’m using have preset Grip positions. So on a player they equip and look normal. It’s equipping with an NPC that ain’t working right
As the images show, ye it does put the tool inside the NPC, but it is being placed a million miles away. Can see in Explorer too that the NPC has all it’s normal parts + Humanoid.