Hello DevForum. My group is trying to utilize an animation that changes how a tool is gripped while it is being played. My group’s animator exported the animation and I scripted it, but the grip does not change as the animation is being played. I couldn’t find many resources on the devforum with regards to this, so I am making one to clarify if it is even possible to do this without manually changing the grip with another script.
Here is my progress on the end result.
What is is supposed to look like, via the editor:
Versus what we end up with when we try
The script we wrote to make the animation play looks like this:
--//Bloxynet and DylanGTech
local player = game.Players.LocalPlayer
repeat wait(1) until player.Character
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animtrack = animator:LoadAnimation(script.Parent.Unsheath)
script.Parent.Equipped:connect(function()
animtrack:Play()
end)
script.Parent.Unequipped:connect(function()
animtrack:Stop()
end)
Essentially, we are looking for a way to have the handle grip changed while the animation is playing, hopefully without trying to manually script a change in the Weld or Motor6D. We have tried replacing the Weld with a Motor6D, but that has not produced a change so far. We also have a localscript made by another user to disable the default “arm out” grip that tools have.
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
function animationPlayed(anim)
local name = anim.Name:lower() -- Get the name of the animation in all lowercase, helps with finding the name.
if name == "toolnoneanim" or name:find("tool") then -- "toolnoneanim" is the name of the tool equip animation, if Roblox happens to change the name it'll look for "tool" in the name.
anim:Stop()
end
end
humanoid.AnimationPlayed:Connect(animationPlayed)
You should use Motor6D for gripping & creating animation for the tool.
The “Arm Out” feature can be disabled by disabling the RequireHandle property of the tool. Though you would need to rig the weapon to the limb using Motor6D on the server. Plus, handle removing them when not equipped.
I’ve tried that method for stopping the “arm out” feature, but it would disable picking up the tool, which is a problem. I found it more effective to use the LocalScript above to disable it. As for using a Motor6D, it doesn’t cause the grip to change with the animation. It may be possible we are not doing it right. Can you give us a sample for how we add it to the rig so it will animate?
When rigging the “Dummy” animation rig with another part/weapon you have to first make sure to check the part count of the weapon model. If there is more than one part, you should Weld them together or use a Motor6D if you wish to animate them individually. Preferably join them with the “Handle” part.
The handle can then be connected to one of the limbs of the character using a Motor6D. Part0 should be the limb and Part1 should be the handle of the weapon. Then you can parent the weapon model/part and Motor6D to the character.
Make sure all the parts in the weapons are un-anchored
There is only one part (the Handle part) and it is unanchored. The team’s animator has tried both the Moon animator and the default Roblox animator plugin. The former does not export the grip changes, and the Roblox animator does not even let him move it. For clarity, the grip is NOT supposed to be constant. It’s supposed to change throughout the animation. So setting C0 and C1 only once after setting the Part0 and Part1 is not going to work for what we’re doing. We’re essentially trying to animate the tool’s handle as if it were a part of the rig.
If you modify the C0 and C1 properties of the Motor6D at all, you need to make sure when the tool is equipped, the created Motor6D uses the same C0 and C1 property as the Motor6D used to animate the weapon. Otherwise your animation will not look accurate to the animation created. As it will be based on the default values of the C0 and C1 properties.