Hello!
I’ve been trying to make an animated weapon, and i wanted to make the character play an animation And the weapon to unfold with the same animation. I connected the weapon’s body attachment (Basically the torso of the weapon) to character’s right arm. I’ve made an animation of the character unfolding the weapon, but i don’t know how to load the animation in both the character and weapon.
Here’s some more information if needed:
So, you’re on the right track with it having an Animation Instance within the tool to help set it up.
To help load the animation for the player, you’ll need to put the ID of said animation into the Animation Instance. Then, you can use a LocalScript to load the animations.
local Humanoid = script.Parent.Parent:FindFirstChild("Humanoid")
local Animation = script.Parent.Animation
if Humanoid and Humanoid.Health < 0 then
local Animator = Humanoid:FindFirstChild("Animator") or Humanoid
local PlayAnim = Animator:LoadAnimation(Animation)
PlayAnim:Play()
end
You can use this batch of code within your local script to attach to an Equipped Event, which would look like this:
script.Parent.Equipped:Connect(function()
local Humanoid = script.Parent.Parent:FindFirstChild("Humanoid")
local Animation = script.Parent.Animation
if Humanoid and Humanoid.Health > 0 then
local Animator = Humanoid:FindFirstChild("Animator") or Humanoid
local PlayAnim = Animator:LoadAnimation(Animation)
PlayAnim:Play()
end
end)
For animating the weapon, you’ll need to know how to Tween the CFrame of the Tool’s GripPosition. I recommend you making two Vector3 Variables. One for the equipped and the other for unequipped.
There is no grip on the weapon, it’s a handleless weapon, the body attach part can get moved in the animator, will that not do the work? Instead of using CFrames?
Asking cause im not too good at those.
You’d have to still CFrame the part though, atleast the Orientation of it. It could be easier if you just welded the part to the player, but it might not give the correct orientation. I’m just saying, and what I mean by CFraming the part it’s actually CFraming the weld of the part.
Local scripts should be able to play it serversided since it’s using the humanoid (perferably the Animator in the humanoid) to play the animation. So it’ll send that animation across to everyone that’s in the game to see.
Hm, i’ve tried the suggesting you gave me, there are no errors, but the animation did not play, i did move the Arm4 part (and the entire model) away from the BodyAttach, do i have to make another animation if i moved it?
Didn’t work, i tried to make the animation play on a activation of the tool, and typed on the end of “If”, print(“Script Made It All The Way To The End”). But when i clicked, the text didn’t print in the output, that could mean that one of the “If” Requirements are not true.
Ah! There we go! Now it works! Only one of the parts in the model moves but that’s probably because i’ve changed it’s position, so i have to redo the animation. But thank you very much! I owe you one!