Tool Disappears when standing still?

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.

1 Like

How should I stop the animation from playing when it’s unequipped? I’m not that experienced yet at scripting sorry

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.

1 Like

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)

If you could provide a video of what exactly is happening it might help better understand what is happening.

robloxapp-20210111-1946528.wmv (1.6 MB)

does that work or should i upload it somewhere else

It just looks like the minigun is attached to your hand and your hand is facing directly down out of sight and possibly through the ground.

1 Like

How should I rotate the hand holding the minigun?

or how should i add weld instead of using handle?

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.

tool.Equipped:Connect(function()
DisableHandOut()
end)

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)

1 Like

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