So, I made a gun works but I wanted to add where you can laydown I did that but it keeps giving me AnimationTrack limit of 256 exuded and the animations stop here is the code:

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local tool = script.Parent
local handle = tool.Handle
local CanFire = true
local MaxAmmo = 6
local ammo = MaxAmmo
local reloading = false
local Open = false
local Animate
tool.Equipped:Connect(function()
		game.Players.LocalPlayer.PlayerGui.GunGUI3.Frame.Visible = true
		game.Players.LocalPlayer.PlayerGui.GunGUI3.Frame.Bullets.Visible = true
		game.Players.LocalPlayer.PlayerGui.Equipped.Frame.Tool.Visible = true
		game.Players.LocalPlayer.PlayerGui.Equipped.Frame.TextLabel.Visible = true
		game.Players.LocalPlayer.PlayerGui.Equipped.Frame.Tool.Text = tool.Name..' Has been Equipped'
		game.Players.LocalPlayer.PlayerGui.Equipped.Frame.TextLabel.Text =  '[2]'
		wait(5)
		game.Players.LocalPlayer.PlayerGui.Equipped.Frame.Tool.Visible = false
		game.Players.LocalPlayer.PlayerGui.Equipped.Frame.TextLabel.Visible = false
end)
tool.Activated:Connect(function()
	if CanFire == true then
		if ammo>0 then
			script.Parent.Aduio:Play()
			CanFire = false
			local ray = Ray.new(handle.CFrame.p, (mouse.Target.CFrame.p - handle.CFrame.p).Unit*700)
		local part, position = game.Workspace:FindPartOnRay(ray, player.Character, false, true)``
		if part then
			if part.Parent:FindFirstChild('Humanoid') then
				script.Parent.Damage:FireServer(mouse.Target.Parent, 20)
			end
		end
		ammo = ammo -1
		game.Players.LocalPlayer.PlayerGui.GunGUI3.Frame.Bullets.Text = "Bullets: "..ammo
	wait(0.2)
	CanFire = true
end
mouse.KeyDown:Connect(function(Key) 
 if Key == "c" then
	local Animation = Instance.new("Animation", player.Character)	
		Animation.AnimationId = "rbxassetid://3892778365"	
			Animate = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(Animation)
 	 	Animate:Play()
 	end  
end)
mouse.KeyDown:Connect(function(Key)
 if Key == "x" then
  Animate:Stop()
 end
end)
	--local animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.laydown)
        	--animation:Stop()
	 mouse.KeyDown:connect(function(key3) 
		if key3 == "r" then
			script.Parent.Audio2:Play()
			game.Players.LocalPlayer.PlayerGui.GunGUI3.Frame.Bullets.Text = "Reloading"
			wait(3)
					ammo = MaxAmmo
				game.Players.LocalPlayer.PlayerGui.GunGUI3.Frame.Bullets.Text = "Bullets: "..ammo
				game.Players.LocalPlayer.PlayerGui.GunGUI3.Frame.Ammo6.Visible = true
				game.Players.LocalPlayer.PlayerGui.GunGUI3.Frame.Ammo5.Visible = true
				game.Players.LocalPlayer.PlayerGui.GunGUI3.Frame.Ammo4.Visible = true
				game.Players.LocalPlayer.PlayerGui.GunGUI3.Frame.Ammo3.Visible = true
				game.Players.LocalPlayer.PlayerGui.GunGUI3.Frame.Ammo2.Visible = true
				game.Players.LocalPlayer.PlayerGui.GunGUI3.Frame.Ammo1.Visible =  true
			end
		end)
	elseif ammo<0 then
		CanFire = false
	end
	if ammo == 5 then
		game.Players.LocalPlayer.PlayerGui.GunGUI3.Frame.Ammo6.Visible = false
	end
	if ammo == 4 then
		game.Players.LocalPlayer.PlayerGui.GunGUI3.Frame.Ammo5.Visible = false
	end
	if ammo == 3 then
		game.Players.LocalPlayer.PlayerGui.GunGUI3.Frame.Ammo4.Visible = false
	end
	if ammo == 2 then
		game.Players.LocalPlayer.PlayerGui.GunGUI3.Frame.Ammo3.Visible = false
	end
	if ammo == 1 then
		game.Players.LocalPlayer.PlayerGui.GunGUI3.Frame.Ammo2.Visible = false
	end
	if ammo == 0 then
		game.Players.LocalPlayer.PlayerGui.GunGUI3.Frame.Ammo1.Visible = false
	end
end)
tool.Unequipped:Connect(function()
	game.Players.LocalPlayer.PlayerGui.GunGUI3.Frame.Visible = false
	game.Players.LocalPlayer.PlayerGui.GunGUI3.Frame.Bullets.Visible = false
	--local animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.laydown)
	Animate:Stop()
end)

1 comment

0

er... can you make it into script format?