Help with gun equipping animation

my gun isn’t stopping when equipped and 2 arms wont stay close together

https://gyazo.com/51586d9203f116003c8c4cb2b6a39bff

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

local Gun = script.Parent.Parent:FindFirstChild('Gun')

local UserInputService = game:GetService('UserInputService')
local TweenService = game:GetService('TweenService')
local Camera = workspace.CurrentCamera
local ReplicatedStorage = game:GetService('ReplicatedStorage')

local Index = {['ZoomIn'] = 60, ['ZoomOut'] = 70}
local Info = TweenInfo.new(0.21, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)


local function TweenCamera(Properties)
	local T = TweenService:Create(game.Workspace.CurrentCamera, Info, Properties)
	T:Play()
end


local equipped = false
local function Zoom(key)
	if Player and Player.Character then
		UserInputService.InputBegan:Connect(function(input)
			if input.UserInputType == Enum.UserInputType[key] then
				if equipped then
				local Properties = {FieldOfView = Index.ZoomIn}
                TweenCamera(Properties)
                Mouse.Icon = ''

                local Animation = Instance.new('Animation')
			    Animation.AnimationId = 'rbxassetid://4842699362'
			
			    local AnimLoad = Player.Character.Humanoid:LoadAnimation(Animation)
			    AnimLoad:Play()
			
			wait(0.5)
			Animation:Destroy()
				end
				end
					end)
						UserInputService.InputEnded:Connect(function(input)
							if input.UserInputType == Enum.UserInputType[key] then
								if equipped then
					      local Properties = {FieldOfView = Index.ZoomOut}
					      TweenCamera(Properties)
					wait(0.1)
					Mouse.Icon = 'rbxassetid://61374156'
					end
					end
							end)
						end
			end
			
					
            
		 Gun.Equipped:Connect(function()
			UserInputService.InputBegan:Connect(function(input)
				if input.KeyCode == Enum.KeyCode.F or input.KeyCode == Enum.KeyCode.ButtonX then
			equipped = true
			Zoom('MouseButton2')
			Mouse.Icon = 'rbxassetid://61374156'
			end
			end)
		end)
		
		
	    
		Gun.Unequipped:Connect(function()
			local Properties = {FieldOfView = Index.ZoomOut}
			TweenCamera(Properties)
				UserInputService.InputEnded:Connect(function(input)
				if input.KeyCode == Enum.KeyCode.F or input.KeyCode == Enum.KeyCode.ButtonX then
					local Propertiesg = {FieldOfView = Index.ZoomOut}
			TweenCamera(Propertiesg)
			equipped = false
			wait(0.1)
			Mouse.Icon = ''
			end
			end)
		end)

You have to make two animations, an equip and a hold animation.

When you pull up the gun, play the equip animation. Once that animation ended, play the hold animation.

A hold animation can be as simple as one keyframe. Make sure that it’s looped.

2 Likes

https://gyazo.com/76a466f9739cbeed6788c5719407d0de

whoops

I mean looping the hold animation, not the equip animation.

-- equip
EquipAnimation:Play()
EquipAnimation.Stopped:Connect(function()
-- hold
HoldAnimation:Play()
end)
1 Like

idk how to loop a hold animation, a contiunous holding animation instead?

There’s a property value called “Looped” when you export a keyframe from the Animation Editor.
Set that to true, export to ROBLOX, get that animation’s ID, that’s your hold animation.

robloxapp-20200401-0604145.wmv (1.1 MB)

not what i wanted really