Hello, I am making an assault rifle using tools but I do not know how to make it so the character will grip both hands on the gun.
Here is an example (not the model I’ll be using):
I was wondering if there was a special way to do this, like playing an animation until the player un-equips it and the animation will stop or something simpler that I was being dumb and didn’t see. Thanks in advance.
Well you could just create a simple animation where you hold the gun with both of your arms and then you could use the .Equipped event so that when you equip the tool then your animation will play, so for example:
Tool.Equipped:Connect(function()
anim:Play()
end)
When you have unequipped the tool then the animation should be gone:
Nope, a loop to the animation else the animation will play and the Player still would only holds the gun with one hand. (In other words a looped animation with only 1 second as lenght)
You wasn’t that specific in terms of answering his question so I used a picture telling him thats the button that you need to press to loop the animation.
well, I tried to do that but I cant load the animation to the Humanoid because I cant reference it. I tried many different ways to do it none of them worked and I always got the same error:
Does anyone know what this means and how can I fix this and here is the code that I used
local tool = script.Parent
local Animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(tool.Animation)
tool.Equipped:connect(function()
Animation:Play()
end)
tool.Unequipped:connect(function()
Animation:Stop()
end)
The local script probably didn’t get time to catch the character so your indexing nil, so I would use player.CharacterAdded:Wait() to wait for the character.
Alternatively, when you load the animation, you can set the Loaded property of the AnimationTrack (the object returned by LoadAnimation() and has the Play() function) to true in script.
local AnimationTrack = Animator:LoadAnimation(Animation) -- replacement of Humanoid:LoadAnimation() because it has been deprecated
AnimationTrack.Looped = true -- this makes the animation play in loop
AnimationTrack:Play()