So I made a minigun and it has a tool equipped animation. Whenever I stand still the tool becomes invisible (it’s still in my backpack) and the animation plays. But whenever I move it appears.
local plr = game:GetService("Players").LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local anim = hum:WaitForChild("Animator"):LoadAnimation(script.Parent:WaitForChild("Minigun"))
local tool = script.Parent
anim.Priority = Enum.AnimationPriority.Movement
tool.Equipped:Connect(function()
anim:Play()
anim.Stopped:Connect(function()
anim:Play()
end)
end)
tool.Unequipped:Connect(function()
anim:Stop()
end)
And there is another problem: The animation on the right arm stops playing when I move.
Events fire once and run the code. For example here It will not yield if it isnt equipped. So you are making the animation repeatedly play even when it is unequipped. Start by making the animation a loop in the animation editor rather than manually loop it forever. Not to mention that it will stack everytime the tool is equipped. Also you are setting its animation priority to movement which will get overriden by several other animations, just set it to action and it should play with top priority.
The way you’re doing right now is correct, its the fact that you’re making it constantly repeat itself that makes stopping it pointless. Since you are stopping the animation not the loop that causes it to restart everytime it is stopped.
tool.Equipped:Connect(function()
anim:Play()
end)
This is enough if your animation has action priority and is looped.
The tool still disappears when I stand still though and the right hand keeps moving so it looks like I can pick up a minigun with one hand. But I’m going to try to make my body transparent and see if the minigun disappears just because its hidden in front of my torso
The issue here seems to be the way the minigun tool is put togheter. And the right hand is just a default animation of a roblox tool, if it has a handle it will use that animation.
I used this script to disable the hand out effect:
local NOHANDOUT_ID = 04484494845
local function DisableHandOut(character)
local Animator = character.Animate
local Animation = Instance.new("Animation")
Animation.AnimationId = "http://www.roblox.com/asset/?id="..NOHANDOUT_ID
local ToolNone = Animator:FindFirstChild("toolnone")
if ToolNone then
local NewTool = Instance.new("StringValue")
NewTool.Name = "toolnone"
Animation.Name = "ToolNoneAnim"
Animation.Parent = NewTool
ToolNone:Destroy()
NewTool.Parent = Animator
end
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
DisableHandOut(character)
end)
end)
I personally would just replace the tool holdout animation with one made for the minigun.
There’s no simple and reliable way to move your hand separately from animations.
Isn’t that what I did though? I’m pretty sure I replaced the tool holdout animation with my minigun animation. Also should I weld the minigun? I’ve tried, I can’t figure out how to make a weld and attach it to my arm
You simply played another animation on top of it, who’s priority is being overriden by other animations.
Here is a function i’ve used in the past.
local character = script.Parent.Parent ----- assuming script is a direct child of the tool
local function DisableHandOut()
local Animator = character.Animate
local Animation = Instance.new("Animation")
Animation.AnimationId = ANIMATIONIDHERE
local ToolNone = Animator:FindFirstChild("toolnone")
if ToolNone then
local NewTool = Instance.new("StringValue")
NewTool.Name = "toolnone"
Animation.Name = "ToolNoneAnim"
Animation.Parent = NewTool
ToolNone:Destroy()
NewTool.Parent = Animator
end
end
You would use it in the equipped event simply like this.
You can get rid of the other script that removes the animation. And no need to do anything when unequipped as it only replaces the animation for holding a tool out.
(If another tool is equipped, it will also need its own animation)
That didn’t seem to work, I removed the remove tool script and animation script and added this inside the tool, changed some things but it just played the default holding animation